package com.yida.gwj.expend.outside.service.impl;

import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import javax.validation.Validator;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.yida.common.core.constant.SecurityConstants;
import com.yida.common.core.domain.R;
import com.yida.common.core.exception.ServiceException;
import com.yida.common.core.utils.DateUtils;
import com.yida.common.core.utils.PageUtils;
import com.yida.common.core.utils.StringUtils;
import com.yida.common.core.utils.bean.BeanUtils;
import com.yida.common.core.utils.bean.BeanValidators;
import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.security.utils.SecurityUtils;
import com.yida.gwj.api.domain.GwjBaseBusinessNum;
import com.yida.gwj.api.domain.GwjConfBusinessFlag;
import com.yida.gwj.api.domain.GwjConfFlow;
import com.yida.gwj.api.domain.GwjConfStep;
import com.yida.gwj.api.domain.dto.GwjExpendHouseAndOwnerDTO;
import com.yida.gwj.api.domain.dto.GwjGVoteProjectStatisticsDataDTO;
import com.yida.gwj.api.service.RemoteGwjConfigService;
import com.yida.gwj.api.service.RemoteGwjVoteService;
import com.yida.gwj.common.domain.GwjBaseBuild;
// import com.yida.gwj.common.domain.GwjBaseBusinessNum;
import com.yida.gwj.common.domain.GwjBaseCommunity;
import com.yida.gwj.common.domain.GwjBaseHouse;
import com.yida.gwj.common.domain.GwjBaseOwner;
import com.yida.gwj.common.domain.mq.MqSendResult;
import com.yida.gwj.common.domain.request.GwjBaseBuildRequest;
import com.yida.gwj.common.enums.GwjBusinessFlagType;
import com.yida.gwj.common.enums.GwjBusinessLogResult;
import com.yida.gwj.common.enums.StepConfigInfoEnum;
import com.yida.gwj.common.handler.MqSendMessageHandler;
import com.yida.gwj.common.utils.CheckDiffList;
import com.yida.gwj.common.utils.GwjEnumUtils;
import com.yida.gwj.expend.outside.annotation.ConfStepConfigCheck;
import com.yida.gwj.expend.outside.config.MaintenanceFundsBusinessConfiguration;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusiness;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessAttachment;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessBuild;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessCommunity;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessHouse;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessInfo;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessLog;
import com.yida.gwj.expend.outside.domain.GwjMaintenanceFundsBusinessOwner;
import com.yida.gwj.expend.outside.domain.dto.AddUseApplyFormDTO;
import com.yida.gwj.expend.outside.domain.dto.AllocatedAmountListDTO;
import com.yida.gwj.expend.outside.domain.dto.AllocatedAmountSelectDTO;
import com.yida.gwj.expend.outside.domain.dto.ApplicationReportDTO;
import com.yida.gwj.expend.outside.domain.dto.ApplyBaseInfoDTO;
import com.yida.gwj.expend.outside.domain.dto.ChangeSchemeDTO;
import com.yida.gwj.expend.outside.domain.dto.CostListDTO;
import com.yida.gwj.expend.outside.domain.dto.DeveloperListDTO;
import com.yida.gwj.expend.outside.domain.dto.GetAttachmentInfoRequest;
import com.yida.gwj.expend.outside.domain.dto.GetBusinessDetailDTO;
import com.yida.gwj.expend.outside.domain.dto.GwjBusinessBaseInfoDTO;
import com.yida.gwj.expend.outside.domain.dto.GwjConfStepDTO;
import com.yida.gwj.expend.outside.domain.dto.GwjHouseOwnerListDTO;
import com.yida.gwj.expend.outside.domain.dto.GwjMaintenanceFundsBusinessListDTO;
import com.yida.gwj.expend.outside.domain.dto.OwnerCheckProveDTO;
import com.yida.gwj.expend.outside.domain.dto.OwnerCommentsDTO;
import com.yida.gwj.expend.outside.domain.dto.StepConfigInfoDTO;
import com.yida.gwj.expend.outside.domain.imp.GwjExpendOutsideBusinessHouseAndOwnerImp;
import com.yida.gwj.expend.outside.domain.message.MaintenanceFundsMqMessageBody;
import com.yida.gwj.expend.outside.domain.message.PreAcceptExamineMessage;
import com.yida.gwj.expend.outside.domain.message.PreAcceptSecondSubmitMessage;
import com.yida.gwj.expend.outside.domain.message.PreAcceptSubmitMessage;
import com.yida.gwj.expend.outside.domain.message.ResultNotifyMessage;
import com.yida.gwj.expend.outside.domain.request.AllocatedAmountRequest;
import com.yida.gwj.expend.outside.domain.request.ApplicationReportRequest;
import com.yida.gwj.expend.outside.domain.request.GwjHouseOwnerListRequest;
import com.yida.gwj.expend.outside.domain.request.GwjInsertHouseRequest;
import com.yida.gwj.expend.outside.domain.request.GwjMaintenanceFundsBusinessAddRequest;
import com.yida.gwj.expend.outside.domain.request.GwjMaintenanceFundsBusinessListRequest;
import com.yida.gwj.expend.outside.domain.request.GwjMaintenanceFundsBusinessRequest;
import com.yida.gwj.expend.outside.domain.request.GwjMaintenanceFundsCommunityListRequest;
import com.yida.gwj.expend.outside.domain.request.GwjSaveChangeSchemeRequest;
import com.yida.gwj.expend.outside.domain.request.HousesUnderBuildRequest;
import com.yida.gwj.expend.outside.domain.request.ShareEquallyMoneyRequest;
import com.yida.gwj.expend.outside.enums.AppropriationWayEnum;
import com.yida.gwj.expend.outside.enums.BusinessAttachmentServerTypeEnum;
import com.yida.gwj.expend.outside.enums.BusinessAttachmentTypeEnum;
import com.yida.gwj.expend.outside.enums.BusinessServerStatusEnum;
import com.yida.gwj.expend.outside.enums.BusinessStatusEnum;
import com.yida.gwj.expend.outside.enums.BusinessTypeEnum;
import com.yida.gwj.expend.outside.enums.FlagStatusEnum;
import com.yida.gwj.expend.outside.enums.MaintenanceFundsErrorEnum;
import com.yida.gwj.expend.outside.enums.SelectFlagEnum;
import com.yida.gwj.expend.outside.mapper.GwjMaintenanceFundsBusinessMapper;
import com.yida.gwj.expend.outside.service.GwjExpendOutsideBaseHouseService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessAttachmentService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessBuildService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessCommunityService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessHouseService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessInfoService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessInnerService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessLogService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessOwnerService;
import com.yida.gwj.expend.outside.service.IGwjMaintenanceFundsBusinessService;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;

/**
 * 公维金维修资金业务Service业务层处理
 *
 * @author lgp
 * @date 2023-02-20
 */
@Service
public class GwjMaintenanceFundsBusinessServiceImpl implements IGwjMaintenanceFundsBusinessService {

    private final Logger log = LoggerFactory.getLogger(GwjMaintenanceFundsBusinessServiceImpl.class);
    private final GwjBusinessFlagType businessFlagType = GwjBusinessFlagType.EXPEND_OUTSIDE;

    @Autowired
    private GwjMaintenanceFundsBusinessMapper gwjMaintenanceFundsBusinessMapper;
    @Autowired
    private IGwjMaintenanceFundsBusinessHouseService gwjMaintenanceFundsBusinessHouseService;
    @Autowired
    private IGwjMaintenanceFundsBusinessInfoService gwjMaintenanceFundsBusinessInfoService;
    @Autowired
    private IGwjMaintenanceFundsBusinessBuildService gwjMaintenanceFundsBusinessBuildService;
    @Autowired
    private IGwjMaintenanceFundsBusinessOwnerService gwjMaintenanceFundsBusinessOwnerService;
    @Autowired
    private IGwjMaintenanceFundsBusinessCommunityService gwjMaintenanceFundsBusinessCommunityService;
    @Autowired
    private IGwjMaintenanceFundsBusinessLogService gwjMaintenanceFundsBusinessLogService;
    @Autowired
    private IGwjMaintenanceFundsBusinessAttachmentService maintenanceFundsBusinessAttachmentService;
    @Autowired
    private IGwjMaintenanceFundsBusinessInnerService maintenanceFundsBusinessInnerService;
    @Autowired
    private MaintenanceFundsBusinessConfiguration maintenanceFundsBusinessConfiguration;
    @Autowired
    private RemoteGwjConfigService remoteGwjConfigService;
    @Autowired
    private MqSendMessageHandler mqSendMessageHandler;
    @Autowired
    private GwjExpendOutsideBaseHouseService gwjExpendOutsideBaseHouseService;

    @Autowired
    private RemoteGwjVoteService remoteGwjVoteService;

    @Autowired
    protected Validator validator;

    @Autowired
    protected SqlSessionFactory sqlSessionFactory;

    // 缴款面积类型 1:实测面积；2：预测面积
    private static final Integer[] depositSizeType = {1, 2};

    /**
     * 查询公维金维修资金业务
     *
     * @param bizId 公维金维修资金业务主键
     * @return 公维金维修资金业务
     */
    // @Cacheable(value = "gwj:maintenance_funds_business", key = "#bizId", unless = "#result == null")
    @Override
    public GwjMaintenanceFundsBusiness selectGwjMaintenanceFundsBusinessByBusinessId(Long bizId) {
        return gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
    }

    /**
     * 查询公维金维修资金业务列表
     *
     * @param maintenanceFundsBusinessListRequest 公维金维修资金业务
     * @return 公维金维修资金业务
     */
    @Override
    public List<GwjMaintenanceFundsBusinessListDTO> getGwjMaintenanceFundsBusinessList(GwjMaintenanceFundsBusinessListRequest maintenanceFundsBusinessListRequest) {
        List<GwjMaintenanceFundsBusinessListDTO> maintenanceFundsBusinessListDTOList = gwjMaintenanceFundsBusinessMapper.getGwjMaintenanceFundsBusinessList(maintenanceFundsBusinessListRequest);
        if (CollectionUtil.isEmpty(maintenanceFundsBusinessListDTOList)) {
            return maintenanceFundsBusinessListDTOList;
        }
        List<GwjConfBusinessFlag> confBusinessFlagList;
        try {
            R<List<GwjConfBusinessFlag>> r = remoteGwjConfigService.selectConfBusinessFlagList(new GwjConfBusinessFlag(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData()) || CollectionUtil.isEmpty(r.getData())) {
                throw new ServiceException(r.getMsg());
            }
            confBusinessFlagList = r.getData();
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectConfBusinessFlagList]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_EXPEND_LIST) + "远程调用 -> [remoteGwjConfigService][selectConfBusinessFlagList]异常");
        }
        List<GwjConfStep> confStepList;
        try {
            R<List<GwjConfStep>> r = remoteGwjConfigService.selectConfStepList(new GwjConfStep(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData()) || CollectionUtil.isEmpty(r.getData())) {
                throw new ServiceException(r.getMsg());
            }
            confStepList = r.getData();
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectConfStepList]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_EXPEND_LIST) + "远程调用 -> [remoteGwjConfigService][selectConfStepList]异常");
        }
        List<GwjConfStep> finalConfStepList = confStepList;
        List<GwjConfBusinessFlag> finalConfBusinessFlagList = confBusinessFlagList;
        maintenanceFundsBusinessListDTOList.forEach(business -> {
            List<GwjConfStep> confStepList1 = finalConfStepList.stream().filter(confStep -> business.getStepId().equals(confStep.getStepId())).collect(Collectors.toList());
            if (CollectionUtil.isNotEmpty(confStepList1)) {
                business.setStepName(confStepList1.get(0).getName());
            }
            List<GwjConfBusinessFlag> confBusinessFlagList1 = finalConfBusinessFlagList.stream().filter(confBusinessFlag -> business.getBizFlagId().equals(confBusinessFlag.getBizFlagId())).collect(Collectors.toList());
            if (CollectionUtil.isNotEmpty(confBusinessFlagList1)) {
                GwjConfBusinessFlag gbf = confBusinessFlagList1.get(0);
                business.setFlowName(gbf.getSubcategory());
                // 20230707 新增
                business.setFlagId(gbf.getBizFlagId());
                business.setFlagName(gbf.getCategory());
            }
        });
        return maintenanceFundsBusinessListDTOList;
    }

    @Override
    public List<GwjMaintenanceFundsBusinessHouse> allocatedAmountCancelList(AllocatedAmountRequest allocatedAmountRequest) {
        return gwjMaintenanceFundsBusinessHouseService.selectCancelHouseList(allocatedAmountRequest);
    }

    /**
     * 新增公维金维修资金业务
     *
     * @param gwjMaintenanceFundsBusiness 公维金维修资金业务
     * @return 结果
     */
    // @CachePut(value = "gwj:maintenance_funds_business", key = "#gwjMaintenanceFundsBusiness.bizId", unless = "#result
    // == null")
    @Override
    public GwjMaintenanceFundsBusiness insertGwjMaintenanceFundsBusiness(GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness) {
        if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessMapper.insertGwjMaintenanceFundsBusiness(gwjMaintenanceFundsBusiness), FlagStatusEnum.SUC.getCode())) {
            return null;
        }
        return gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(gwjMaintenanceFundsBusiness.getBizId());
    }

    /**
     * 新增公维金使用资金申请业务
     *
     * @param gwjMaintenanceFundsBusinessAddRequest 公维金维修资金业务
     * @return int 影响行数
     */
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
    @Override
    public AddUseApplyFormDTO addMaintenanceFundsBusinessForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest) {
        if (ObjectUtil.equal(gwjMaintenanceFundsBusinessAddRequest.getAppropriationWay(), AppropriationWayEnum.ONE.getCode())) {
            gwjMaintenanceFundsBusinessAddRequest.setBudgetAppropriationAmount(BigDecimal.ZERO);
        }
        if (ObjectUtil.equal(gwjMaintenanceFundsBusinessAddRequest.getAppropriationWay(), AppropriationWayEnum.TWO.getCode())) {
            int compareTo = gwjMaintenanceFundsBusinessAddRequest.getBudgetAppropriationAmount().compareTo(NumberUtil.mul(gwjMaintenanceFundsBusinessAddRequest.getProjectBudgetAmount(), BigDecimal.valueOf(0.5)));
            if (compareTo > 0) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "预算拨出金额不能大于工程预算的50%");
            }
            int compare = gwjMaintenanceFundsBusinessAddRequest.getBudgetAppropriationAmount().compareTo(BigDecimal.ZERO);
            if (compare < 0) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "预算拨出金额必须大于等于0");
            }
        }
        GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness = new GwjMaintenanceFundsBusiness();
        try {
            R<GwjConfBusinessFlag> r = remoteGwjConfigService.selectGwjConfBusinessFlagByBizFlagId(gwjMaintenanceFundsBusinessAddRequest.getBusinessFlagType(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                throw new ServiceException("远程调用获取配置失败");
            }
            gwjMaintenanceFundsBusiness.setFlowId(r.getData().getFlowId());
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectGwjConfBusinessFlagByBizFlagId]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "远程调用 -> [remoteGwjConfigService][selectGwjConfBusinessFlagByBizFlagId]异常");
        }
        try {
            R<List<GwjConfStep>> r = remoteGwjConfigService.selectGwjConfStepListByFlagId(gwjMaintenanceFundsBusinessAddRequest.getBusinessFlagType(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                throw new ServiceException(r.getMsg());
            }
            gwjMaintenanceFundsBusiness.setStepId(r.getData().get(0).getStepId());
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectGwjConfStepListByFlagId]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "远程调用 -> [remoteGwjConfigService][selectGwjConfStepListByFlagId]异常");
        }
        gwjMaintenanceFundsBusiness.setAreaId(gwjMaintenanceFundsBusinessAddRequest.getAreaId());
        // gwjMaintenanceFundsBusiness.setApplicantUserId(SecurityUtils.getLoginUser().getUserid());
        // gwjMaintenanceFundsBusiness.setApplicantUserName(SecurityUtils.getLoginUser().getUsername());
        gwjMaintenanceFundsBusiness.setStatus(BusinessStatusEnum.SAVE.getCode());
        gwjMaintenanceFundsBusiness.setServerStatus(BusinessServerStatusEnum.NORMAL.getCode());
        gwjMaintenanceFundsBusiness.setApplicantTime(LocalDateTime.now());
        gwjMaintenanceFundsBusiness.setBizFlagId(gwjMaintenanceFundsBusinessAddRequest.getBusinessFlagType());
        gwjMaintenanceFundsBusiness.setServerIdentification(IdUtil.getSnowflakeNextIdStr());
        gwjMaintenanceFundsBusiness.setContacts(gwjMaintenanceFundsBusinessAddRequest.getContacts());
        gwjMaintenanceFundsBusiness.setPhone(gwjMaintenanceFundsBusinessAddRequest.getPhone());
        gwjMaintenanceFundsBusiness.setBizName(gwjMaintenanceFundsBusinessAddRequest.getBizName());
        gwjMaintenanceFundsBusiness.setAddress(gwjMaintenanceFundsBusinessAddRequest.getAddress());
        gwjMaintenanceFundsBusiness.setValidDate(gwjMaintenanceFundsBusinessAddRequest.getValidDate());
        gwjMaintenanceFundsBusiness.setCompletedTime(gwjMaintenanceFundsBusinessAddRequest.getCompletedTime());
        gwjMaintenanceFundsBusiness.setSupplementFlag(FlagStatusEnum.FAL.getCode());
        gwjMaintenanceFundsBusiness.setFinancialJournalFlag(FlagStatusEnum.FAL.getCode());
        gwjMaintenanceFundsBusiness.setType(gwjMaintenanceFundsBusinessAddRequest.getType());
        gwjMaintenanceFundsBusiness.setVoteFlag(FlagStatusEnum.FAL.getCode());
        // 20230613 hmh 新增当前办事人员信息 start
        Long userId = SecurityUtils.getLoginUser().getUserid();
        String userName = SecurityUtils.getLoginUser().getSysOutsideUser().getRealName();
        gwjMaintenanceFundsBusiness.setApplicantUserId(userId);
        gwjMaintenanceFundsBusiness.setApplicantUserName(userName);
        gwjMaintenanceFundsBusiness.setCurrentOperId(userId);
        gwjMaintenanceFundsBusiness.setCurrentOperName(userName);
        // end
        try {
            R<GwjBaseBusinessNum> r = remoteGwjConfigService.getNextNum(gwjMaintenanceFundsBusinessAddRequest.getAreaId(), Convert.toInt(businessFlagType.getCode()), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                throw new ServiceException(r.getMsg());
            }
            Long bizNum = Convert.toLong(r.getData().toString());
            gwjMaintenanceFundsBusiness.setBizNum(bizNum);
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][getNextNum]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "远程调用 -> [remoteGwjConfigService][getNextNum]异常");
        }
        if (ObjectUtil.isNull(((IGwjMaintenanceFundsBusinessService)AopContext.currentProxy()).insertGwjMaintenanceFundsBusiness(gwjMaintenanceFundsBusiness))) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "新增公维金资金申请业务失败");
        }
        gwjMaintenanceFundsBusinessAddRequest.setBizId(gwjMaintenanceFundsBusiness.getBizId());
        try {
            // 插入社区信息
            addCommunityForm(gwjMaintenanceFundsBusinessAddRequest);
            // 插入楼栋信息
            editBuildForm(gwjMaintenanceFundsBusinessAddRequest);
            // 插入房屋信息
            List<GwjInsertHouseRequest> baseHouseList = editHouseForm(gwjMaintenanceFundsBusinessAddRequest);
            // 插入业主信息
            editOwnerForm(gwjMaintenanceFundsBusinessAddRequest, baseHouseList);
            // 插入info信息
            addInfoForm(gwjMaintenanceFundsBusinessAddRequest, baseHouseList);
            // 插入log信息
            int insertFlag = gwjMaintenanceFundsBusinessLogService.insertGwjMaintenanceFundsBusinessLog(new GwjMaintenanceFundsBusinessLog() {
                {
                    setResult(GwjBusinessLogResult.SAVE.getCode());
                    setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                    setStepId(gwjMaintenanceFundsBusinessAddRequest.getStepId());
                }
            });
            if (ObjectUtil.equal(FlagStatusEnum.FAL.getCode(), insertFlag)) {
                throw new ServiceException("GwjMaintenanceFundsBusinessLog新增失败");
            }
        } catch (Exception e) {
            log.error("插入公维金维修资金使用申请异常 -> [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + e.getMessage());
        }
        return new AddUseApplyFormDTO() {
            {
                setBizId(gwjMaintenanceFundsBusiness.getBizId());
                setServerIdentification(gwjMaintenanceFundsBusiness.getServerIdentification());
            }

        };
    }

    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
    public void addCommunityForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest) {
        // 获取基础房屋信息
        List<GwjBaseBuild> gwjBaseBuilds = maintenanceFundsBusinessInnerService.selectGwjBaseBuildListByCommunityId(gwjMaintenanceFundsBusinessAddRequest.getCommunityId());
        if (CollectionUtil.isEmpty(gwjBaseBuilds)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "获取基础房屋信息失败");
        }
        // 计算小区建筑总面积 小区期房总面积 小区业主总户数
        BigDecimal totalSize = new BigDecimal(0);
        BigDecimal periodSize = new BigDecimal(0);
        int totalOwner = 0;
        for (GwjBaseBuild build : gwjBaseBuilds) {
            totalSize = totalSize.add(Optional.ofNullable(build.getTotalSize()).orElse(BigDecimal.ZERO));
            periodSize = periodSize.add(Optional.ofNullable(build.getPeriodSize()).orElse(BigDecimal.ZERO));
            totalOwner += Optional.ofNullable(build.getTotalOwner()).orElse(0);
        }
        BigDecimal finalTotalSize = totalSize;
        BigDecimal finalPeriodSize = periodSize;
        Integer finalTotalOwner = totalOwner;
        // 获取基础社区信息
        GwjBaseCommunity gwjBaseCommunity = maintenanceFundsBusinessInnerService.selectGwjBaseCommunityByGwjBaseCommunityId(gwjMaintenanceFundsBusinessAddRequest.getCommunityId());
        if (ObjectUtil.isNull(gwjBaseCommunity)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "获取基础社区信息失败");
        }
        GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity = new GwjMaintenanceFundsBusinessCommunity() {
            {
                setCreateTime(DateUtils.getNowDate());
                setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                setCommunityId(gwjMaintenanceFundsBusinessAddRequest.getCommunityId());
                setCommunityName(gwjMaintenanceFundsBusinessAddRequest.getCommunityName());
                setAreaId(gwjBaseCommunity.getAreaId());
                setStreetId(gwjBaseCommunity.getStreetId());
                setOwnerCommitteeId(gwjBaseCommunity.getCommitteeId());
                setDevelopmentEnterpriseId(gwjBaseCommunity.getCompanyId());
                setDevelopmentEnterpriseName(gwjMaintenanceFundsBusinessAddRequest.getDevelopmentEnterpriseName());
                setBankId(gwjBaseCommunity.getBankId());
                // setCommunityLocation(gwjBaseCommunity.getCommunityLocation());
                // 20230626 临时新增，从业务地址中进行抽出 start
                setCommunityLocation(gwjMaintenanceFundsBusinessAddRequest.getAddress());
                // end
                setTotalSize(finalTotalSize);
                setForwardHouseSize(finalPeriodSize);
                setOwnerCommitteeName(gwjMaintenanceFundsBusinessAddRequest.getOwnerCommitteeName());
                setTotalBuild(gwjBaseBuilds.size());
                setTotalOwner(finalTotalOwner);
            }
        };
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusinessCommunityService.insertGwjMaintenanceFundsBusinessCommunity(gwjMaintenanceFundsBusinessCommunity))) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "新增公维金资金申请社区信息失败");
        }
    }

    public void addInfoForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest, List<GwjInsertHouseRequest> baseHouseList) {
        BigDecimal totalArea = new BigDecimal(0);
        for (GwjInsertHouseRequest house : baseHouseList) {
            if (ObjectUtil.equals(house.getActualSize(), BigDecimal.ZERO)) {
                totalArea = totalArea.add(house.getForecastSize());
            } else {
                totalArea = totalArea.add(house.getActualSize());
            }
        }
        BigDecimal finalTotalArea = totalArea;
        GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo = new GwjMaintenanceFundsBusinessInfo() {
            {
                setCreateTime(DateUtils.getNowDate());
                setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                setMaintenanceItems(gwjMaintenanceFundsBusinessAddRequest.getMaintenanceItems());
                setMaintenanceReason(gwjMaintenanceFundsBusinessAddRequest.getMaintenanceReason());
                setDeclarationDate(gwjMaintenanceFundsBusinessAddRequest.getDeclarationDate());
                setProjectBudgetAmount(gwjMaintenanceFundsBusinessAddRequest.getProjectBudgetAmount());
                setAppropriationWay(gwjMaintenanceFundsBusinessAddRequest.getAppropriationWay());
                setBudgetAppropriationAmount(gwjMaintenanceFundsBusinessAddRequest.getBudgetAppropriationAmount());
                setConstructionUnit(gwjMaintenanceFundsBusinessAddRequest.getConstructionUnit());
                setPayeeName(gwjMaintenanceFundsBusinessAddRequest.getPayeeName());
                setBankDeposit(gwjMaintenanceFundsBusinessAddRequest.getBankDeposit());
                setCollectionAccount(gwjMaintenanceFundsBusinessAddRequest.getCollectionAccount());
                setTotalHouseholds(baseHouseList.size());
                setTotalInvolvedArea(finalTotalArea);
                setAcceptancePlan(gwjMaintenanceFundsBusinessAddRequest.getAcceptancePlan());
                setApplicationUnitName(gwjMaintenanceFundsBusinessAddRequest.getApplicationUnitName());
                // 20230710 hmh add bankId
                setBankId(gwjMaintenanceFundsBusinessAddRequest.getBankId());
            }
        };
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusinessInfoService.insertGwjMaintenanceFundsBusinessInfo(gwjMaintenanceFundsBusinessInfo))) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "新增公维金资金申请info信息失败");
        }
    }

    // 根据文件枚举插入报告空串
    public void addBlankAttachment(List<BusinessAttachmentServerTypeEnum> attachmentServerTypeEnumList, String serverIdentification) {
        ArrayList<GwjMaintenanceFundsBusinessAttachment> attachmentList = new ArrayList<GwjMaintenanceFundsBusinessAttachment>();
        attachmentServerTypeEnumList.forEach(attachmentServerTypeEnum -> attachmentList.add(new GwjMaintenanceFundsBusinessAttachment() {
            {
                setType(BusinessAttachmentTypeEnum.REPORT.getCode());
                setServerType(attachmentServerTypeEnum.getCode());
                setServerIdentification(serverIdentification);
                setContent("{}");
            }
        }));
        maintenanceFundsBusinessAttachmentService.insertBatchAttachment(attachmentList);
    }

    /**
     * 修改公维金维修资金业务
     *
     * @param gwjMaintenanceFundsBusiness 公维金维修资金业务
     * @return 结果
     */
    // @CachePut(value = "gwj:maintenance_funds_business", key = "#gwjMaintenanceFundsBusiness.bizId", unless = "#result
    // == null")
    @Override
    public GwjMaintenanceFundsBusiness updateGwjMaintenanceFundsBusiness(GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness) {
        // 20230710 统一新增当前办理人员 start
        // gwjMaintenanceFundsBusiness.setCurrentOperId(SecurityUtils.getUserId());
        // gwjMaintenanceFundsBusiness.setCurrentOperName(SecurityUtils.getUsername());
        gwjMaintenanceFundsBusiness.setUpdateBy(SecurityUtils.getUsername());
        // end
        if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessMapper.updateGwjMaintenanceFundsBusiness(gwjMaintenanceFundsBusiness), FlagStatusEnum.SUC.getCode())) {
            return null;
        }
        return gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(gwjMaintenanceFundsBusiness.getBizId());
    }

    @ConfStepConfigCheck(bizId = "#bizId", stepConfigInfo = {StepConfigInfoEnum.SUBMIT}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public PreAcceptSubmitMessage preAcceptSubmit(Long bizId, List<BusinessAttachmentServerTypeEnum> attachmentServerTypeEnumList) {
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            throw new ServiceException("GwjMaintenanceFundsBusiness为空");
        }
        // 1.分摊金额
        GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(bizId);
        switch (BusinessTypeEnum.translate(maintenanceFundsBusiness.getType())) {
            case PREPARE:
            case URGENT_PREPARE:
                // 申请 工程预算
                if (ObjectUtil.notEqual(maintenanceFundsBusinessInfo.getActualAllocationAmount(), maintenanceFundsBusinessInfo.getProjectBudgetAmount())) {
                    throw new ServiceException("存在分摊金额不等于预拨款金额");
                }
                // 20230726 新增判断 申请时候如果是二次拨付，预算拨出总金额不能大于工程预算得50%并且大于0 s
                // 预算拨款金额
                BigDecimal budgetAppropriationAmount = maintenanceFundsBusinessInfo.getBudgetAppropriationAmount();
                // 工程预算金额
                BigDecimal projectBudgetAmount = maintenanceFundsBusinessInfo.getProjectBudgetAmount();
                // 工程预算50%标准
                // 保留两位小数
                // DecimalFormat decimal = new DecimalFormat("#0.00");
                BigDecimal halfBudgetAppropriationAmount = projectBudgetAmount.multiply(new BigDecimal("0.5")).setScale(2, BigDecimal.ROUND_HALF_UP);
                // String halfBudgetAppropriationAmountView = decimal.format(halfBudgetAppropriationAmount);
                // 二次拨付，大于0，小于预算50%
                if (maintenanceFundsBusinessInfo.getAppropriationWay() == 2 && budgetAppropriationAmount.compareTo(BigDecimal.ZERO) == 1 && budgetAppropriationAmount.compareTo(halfBudgetAppropriationAmount) == 1) {
                    throw new ServiceException("当前预算金额[" + budgetAppropriationAmount + "]大于工程预算[" + projectBudgetAmount + "]的50%[" + halfBudgetAppropriationAmount + "]，请调整后再提交！");
                }
                // e
                break;
            case APPROPRIATE_PREPARE:
            case URGENT_APPROPRIATE_PREPARE:
                // 拨付 决算总金额
                if (ObjectUtil.notEqual(maintenanceFundsBusinessInfo.getActualAllocationAmount(), maintenanceFundsBusinessInfo.getTotalSettlementAmount())) {
                    throw new ServiceException("存在决算拨出总金额不等于决算总金额");
                }
                break;
            default:
                throw new ServiceException("业务类型不正确");
        }
        // 20230616 修订 新增不查询文件服务器操作
        // List<GwjMaintenanceFundsBusinessAttachment> maintenanceFundsBusinessAttachmentList =
        // maintenanceFundsBusinessAttachmentService.selectGwjMaintenanceFundsBusinessAttachmentList(new
        // GwjMaintenanceFundsBusinessAttachment() {
        List<GwjMaintenanceFundsBusinessAttachment> maintenanceFundsBusinessAttachmentList = maintenanceFundsBusinessAttachmentService.selectGwjMaintenanceFundsBusinessAttachmentListNoFileService(new GwjMaintenanceFundsBusinessAttachment() {
            {
                setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
            }
        });
        // 2.检查附件是否上传
        List<BusinessAttachmentServerTypeEnum> serverTypeEnumList = maintenanceFundsBusinessAttachmentService.checkNull(() -> {
            return Optional.of(maintenanceFundsBusinessAttachmentList);
        }, false, attachmentServerTypeEnumList);
        if (CollectionUtil.isNotEmpty(serverTypeEnumList)) {
            throw new ServiceException("附件" + serverTypeEnumList.get(0).getInfo() + "不能为空,请先上传");
        }
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness1 = new GwjMaintenanceFundsBusiness();
        maintenanceFundsBusiness1.setBizId(bizId);
        maintenanceFundsBusiness1.setStatus(BusinessStatusEnum.SUBMIT.getCode());
        maintenanceFundsBusiness1.setServerStatus(BusinessServerStatusEnum.NORMAL.getCode());
        maintenanceFundsBusiness1.setStepId(maintenanceFundsBusiness.getStepId());
        if (ObjectUtil.notEqual(maintenanceFundsBusiness.getStatus(), BusinessStatusEnum.RETREAT_PARTS.getCode())) {
            try {
                R<GwjConfStep> r = remoteGwjConfigService.selectNextGwjConfStepByFlagId(maintenanceFundsBusiness.getBizFlagId(), maintenanceFundsBusiness.getStepId(), SecurityConstants.INNER);
                if (R.isError(r)) {
                    throw new ServiceException(r.getMsg());
                }
                if (ObjectUtil.isNull(r.getData())) {
                    // 这里只配一个步骤时候会报空指针异常
                    throw new ServiceException("未获取到对应步骤信息！");
                }
                maintenanceFundsBusiness1.setStepId(r.getData().getStepId());
            } catch (Exception e) {
                log.error("远程调用 -> [remoteGwjConfigService][selectNextGwjConfStepByFlagId]异常,异常信息: [{}]", e);
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SUBMIT) + "远程调用 -> [remoteGwjConfigService][selectNextGwjConfStepByFlagId]异常");
            }
        }
        Optional.ofNullable(((IGwjMaintenanceFundsBusinessService)AopContext.currentProxy()).updateGwjMaintenanceFundsBusiness(maintenanceFundsBusiness1)).<ServiceException>orElseThrow(() -> {
            throw new ServiceException("GwjMaintenanceFundsBusiness更新失败");
        });
        maintenanceFundsBusiness.setStatus(BusinessStatusEnum.SUBMIT.getCode());
        int insertFlag = gwjMaintenanceFundsBusinessLogService.insertGwjMaintenanceFundsBusinessLog(new GwjMaintenanceFundsBusinessLog() {
            {
                setResult(GwjBusinessLogResult.SUBMIT.getCode());
                setBizId(maintenanceFundsBusiness1.getBizId());
                setStepId(maintenanceFundsBusiness1.getStepId());
            }
        });
        if (ObjectUtil.equal(FlagStatusEnum.FAL.getCode(), insertFlag)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SUBMIT) + "GwjMaintenanceFundsBusinessLog新增失败");
        }
        List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new GwjMaintenanceFundsBusinessHouse() {
            {
                setBizId(bizId);
            }
        });
        List<GwjMaintenanceFundsBusinessBuild> maintenanceFundsBusinessBuildList = gwjMaintenanceFundsBusinessBuildService.selectGwjMaintenanceFundsBusinessBuildList(new GwjMaintenanceFundsBusinessBuild() {
            {
                setBizId(bizId);
            }
        });
        List<GwjMaintenanceFundsBusinessOwner> maintenanceFundsBusinessOwnerList = gwjMaintenanceFundsBusinessOwnerService.selectGwjMaintenanceFundsBusinessOwnerList(new GwjMaintenanceFundsBusinessOwner() {
            {
                setBizId(bizId);
            }
        });
        GwjMaintenanceFundsBusinessCommunity maintenanceFundsBusinessCommunity = gwjMaintenanceFundsBusinessCommunityService.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(bizId);
        return new PreAcceptSubmitMessage() {
            {
                setMaintenanceFundsBusiness(maintenanceFundsBusiness);
                setMaintenanceFundsBusinessInfo(maintenanceFundsBusinessInfo);
                setMaintenanceFundsBusinessCommunity(maintenanceFundsBusinessCommunity);
                setMaintenanceFundsBusinessBuildList(maintenanceFundsBusinessBuildList);
                setMaintenanceFundsBusinessHouseList(maintenanceFundsBusinessHouseList);
                setMaintenanceFundsBusinessOwnerList(maintenanceFundsBusinessOwnerList);
                setMaintenanceFundsBusinessAttachmentList(maintenanceFundsBusinessAttachmentList);
            }
        };
    }

    /**
     * 分摊金额-已选择列表
     *
     * @param allocatedAmountRequest
     * @return AllocatedAmountSelectDTO
     */
    @Override
    public AllocatedAmountSelectDTO allocatedAmountList(AllocatedAmountRequest allocatedAmountRequest, GwjBusinessFlagType businessFlagType) {
        List<AllocatedAmountListDTO> maintenanceFundsBusinessHouseList = gwjMaintenanceFundsBusinessHouseService.allocatedAmountList(allocatedAmountRequest);
        List<AllocatedAmountListDTO> maintenanceFundsBusinessHouseList1 = gwjMaintenanceFundsBusinessHouseService.allocatedAmountList(allocatedAmountRequest);
        GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(allocatedAmountRequest.getBizId());
        if (ObjectUtil.isNull(maintenanceFundsBusinessInfo)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) + "GwjMaintenanceFundsBusinessInfo为空");
        }
        BigDecimal selfRaiseMoney = BigDecimal.ZERO;
        BigDecimal totalAllocationMoney = BigDecimal.ZERO;
        BigDecimal actualAllocationMoney = BigDecimal.ZERO;
        if (CollectionUtil.isNotEmpty(maintenanceFundsBusinessHouseList1)) {
            selfRaiseMoney = maintenanceFundsBusinessHouseList1.stream().map(AllocatedAmountListDTO::getSelfRaiseMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
            totalAllocationMoney = maintenanceFundsBusinessHouseList1.stream().map(AllocatedAmountListDTO::getTotalAllocationMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
            actualAllocationMoney = maintenanceFundsBusinessHouseList1.stream().map(AllocatedAmountListDTO::getActualAllocationMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
        }
        List<String> useTypeList = gwjMaintenanceFundsBusinessHouseService.selectUseTypeList();
        if (CollectionUtil.isEmpty(useTypeList)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) + "useTypeList为空");
        }
        AllocatedAmountSelectDTO allocatedAmountSelectDTO = new AllocatedAmountSelectDTO();
        allocatedAmountSelectDTO.setSelfRaiseMoney(selfRaiseMoney);
        allocatedAmountSelectDTO.setTotalAllocationMoney(totalAllocationMoney);
        allocatedAmountSelectDTO.setActualAllocationMoney(actualAllocationMoney);
        allocatedAmountSelectDTO.setTotalHouseholds(maintenanceFundsBusinessInfo.getTotalHouseholds());
        allocatedAmountSelectDTO.setTotalAreaInvolved(maintenanceFundsBusinessInfo.getTotalInvolvedArea());

        allocatedAmountSelectDTO.setTableDataInfo(PageUtils.getDataTable(maintenanceFundsBusinessHouseList));
        allocatedAmountSelectDTO.setUseTypeList(useTypeList);
        switch (GwjBusinessFlagType.translate(businessFlagType.getCode())) {
            case EXPEND_OUTSIDE:
            case EXPEND_OUTSIDE_URGENT:
                allocatedAmountSelectDTO.setProjectBudgetAmount(maintenanceFundsBusinessInfo.getProjectBudgetAmount());
                break;
            case EXPEND_OUTSIDE_APPROPRIATE:
            case EXPEND_OUTSIDE_URGENT_APPROPRIATE:
                allocatedAmountSelectDTO.setProjectBudgetAmount(maintenanceFundsBusinessInfo.getTotalSettlementAmount());
                break;
            default:
                break;
        }
        return allocatedAmountSelectDTO;
    }

    // /**
    // * 按类型平摊金额 计算标准
    // *
    // * @param shareEquallyMoneyRequest
    // * @return AllocatedAmountSelectDTO
    // */
    // @ConfStepConfigCheck(bizId = "#shareEquallyMoneyRequest.bizId", stepConfigInfo = {StepConfigInfoEnum.SAVE},
    // businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    // @Transactional(rollbackFor = Exception.class)
    // @Override
    // public int shareEquallyMoney(ShareEquallyMoneyRequest shareEquallyMoneyRequest) {
    // GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness =
    // selectGwjMaintenanceFundsBusinessByBusinessId(shareEquallyMoneyRequest.getBizId());
    // if (ObjectUtil.isNull(gwjMaintenanceFundsBusiness)) {
    // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) +
    // "GwjMaintenanceFundsBusiness为空");
    // }
    // if (ObjectUtil.equals(gwjMaintenanceFundsBusiness.getSupplementFlag(), FlagStatusEnum.SUC.getCode())) {
    // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) +
    // "二次补件不允许修改分摊金额");
    // }
    // GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo =
    // gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(shareEquallyMoneyRequest.getBizId());
    // if (NumberUtil.equals(BigDecimal.ZERO, maintenanceFundsBusinessInfo.getTotalInvolvedArea())) {
    // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) +
    // "分摊总面积不能为0");
    // }
    // // 公用户不参与分摊
    // List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList =
    // gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new
    // GwjMaintenanceFundsBusinessHouse() {
    // {
    // setSelectFlag(SelectFlagEnum.SELECT.getCode());
    // setBizId(shareEquallyMoneyRequest.getBizId());
    // // setPublicFlag(0);// 修订取消注释 20230703 hmh
    // setSelectFlag(1);// 增加已选中房屋判断 hmh
    // }
    // });
    // if (CollectionUtil.isEmpty(maintenanceFundsBusinessHouseList)) {
    // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) +
    // "List<GwjMaintenanceFundsBusinessHouse>为空");
    // }
    // AtomicReference<BigDecimal> totalAllocationMoney = new AtomicReference<>(BigDecimal.ZERO);
    // maintenanceFundsBusinessHouseList.forEach(house -> {
    // house.setLackMoney(BigDecimal.ZERO);
    // house.setSelfRaiseMoney(BigDecimal.ZERO);
    // BigDecimal allocationMoney = BigDecimal.ZERO;
    // // 按面积计算公式:(房屋面积/总面积)*分摊金额,截取小数点后两位,剩下的进行补差额
    // if (ObjectUtil.equal(StandardTypeEnum.AREA.getCode(), shareEquallyMoneyRequest.getStandardType())) {
    // if (NumberUtil.equals(maintenanceFundsBusinessInfo.getTotalInvolvedArea(), BigDecimal.ZERO)) {
    // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) +
    // "涉及总面积不能为0");
    // }
    // allocationMoney = NumberUtil.mul(NumberUtil.div(ObjectUtil.equal(house.getActualSize(), BigDecimal.ZERO) ?
    // house.getForecastSize() : house.getActualSize(), maintenanceFundsBusinessInfo.getTotalInvolvedArea()),
    // maintenanceFundsBusinessInfo.getProjectBudgetAmount());
    // house.setAllocationMoney(allocationMoney);
    // }
    // // 按户数计算公式:分摊金额/户数,截取小数点后两位,剩下的进行补差额
    // if (ObjectUtil.equal(StandardTypeEnum.OWNER.getCode(), shareEquallyMoneyRequest.getStandardType())) {
    // allocationMoney = NumberUtil.div(maintenanceFundsBusinessInfo.getProjectBudgetAmount(),
    // maintenanceFundsBusinessInfo.getTotalHouseholds(), 2, RoundingMode.HALF_UP);
    // house.setAllocationMoney(allocationMoney);
    // }
    // house.setTotalAllocationMoney(allocationMoney);
    // house.setActualAllocationMoney(allocationMoney);
    // totalAllocationMoney.set(NumberUtil.add(totalAllocationMoney.get(), allocationMoney));
    // });
    // Optional.ofNullable(gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfoByBusinessId(new
    // GwjMaintenanceFundsBusinessInfo() {
    // {
    // setActualAllocationAmount(totalAllocationMoney.get());
    // setBizId(maintenanceFundsBusinessInfo.getBizId());
    // setCalculationStandard(shareEquallyMoneyRequest.getStandardType());
    // }
    // })).<ServiceException>orElseThrow(() -> {
    // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) +
    // "GwjMaintenanceFundsBusinessInfo更新失败");
    // });
    // return
    // gwjMaintenanceFundsBusinessHouseService.updateBatchGwjMaintenanceFundsBusinessHouse(maintenanceFundsBusinessHouseList);
    // }

    /**
     * 按类型平摊金额 计算标准
     * <p>
     * 20230713
     * <p>
     * hmh
     *
     * @param shareEquallyMoneyRequest
     * @return AllocatedAmountSelectDTO
     */
    @ConfStepConfigCheck(bizId = "#shareEquallyMoneyRequest.bizId", stepConfigInfo = {StepConfigInfoEnum.SAVE}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int shareEquallyMoney(ShareEquallyMoneyRequest shareEquallyMoneyRequest) {
        GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness = selectGwjMaintenanceFundsBusinessByBusinessId(shareEquallyMoneyRequest.getBizId());
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusiness)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) + "GwjMaintenanceFundsBusiness为空");
        }
        if (ObjectUtil.equals(gwjMaintenanceFundsBusiness.getSupplementFlag(), FlagStatusEnum.SUC.getCode())) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) + "二次补件不允许修改分摊金额");
        }
        GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(shareEquallyMoneyRequest.getBizId());
        if (NumberUtil.equals(BigDecimal.ZERO, maintenanceFundsBusinessInfo.getTotalInvolvedArea())) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) + "分摊总面积不能为0");
        }
        // 公用户不参与分摊
        List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new GwjMaintenanceFundsBusinessHouse() {
            {
                setSelectFlag(SelectFlagEnum.SELECT.getCode());
                setBizId(shareEquallyMoneyRequest.getBizId());
                // setPublicFlag(0);// 修订取消注释 20230703 hmh
                // setSelectFlag(1);// 增加已选中房屋判断 hmh
            }
        });
        if (CollectionUtil.isEmpty(maintenanceFundsBusinessHouseList)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) + "List<GwjMaintenanceFundsBusinessHouse>为空");
        }
        AtomicReference<BigDecimal> totalAllocationMoney = new AtomicReference<>(BigDecimal.ZERO);
        // 涉及总面积为0
        if (NumberUtil.equals(maintenanceFundsBusinessInfo.getTotalInvolvedArea(), BigDecimal.ZERO)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) + "涉及总面积不能为0");
        }
        Integer standardType = shareEquallyMoneyRequest.getStandardType();
        // 提示信息
        StringBuffer sb = new StringBuffer();
        maintenanceFundsBusinessHouseList.forEach(house -> {
            house.setLackMoney(BigDecimal.ZERO);
            house.setSelfRaiseMoney(BigDecimal.ZERO);
            BigDecimal allocationMoney = BigDecimal.ZERO;
            // 缴款面积
            BigDecimal depositSize = BigDecimal.ZERO;
            // 按面积计算公式:(房屋面积/总面积)*分摊金额,截取小数点后两位,剩下的进行补差额
            // if (ObjectUtil.equal(StandardTypeEnum.AREA.getCode(), shareEquallyMoneyRequest.getStandardType())) {
            // if (NumberUtil.equals(maintenanceFundsBusinessInfo.getTotalInvolvedArea(), BigDecimal.ZERO)) {
            // throw new
            // ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) +
            // "涉及总面积不能为0");
            // }
            // allocationMoney = NumberUtil.mul(NumberUtil.div(ObjectUtil.equal(house.getActualSize(), BigDecimal.ZERO)
            // ? house.getForecastSize() : house.getActualSize(), maintenanceFundsBusinessInfo.getTotalInvolvedArea()),
            // maintenanceFundsBusinessInfo.getProjectBudgetAmount());
            // house.setAllocationMoney(allocationMoney);
            // }
            // 20230717
            // 实测面积（现房）
            BigDecimal actualSize = StringUtils.isNull(house.getActualSize()) ? BigDecimal.ZERO : house.getActualSize();
            // 预测面积（期房）
            BigDecimal forecastSize = StringUtils.isNull(house.getForecastSize()) ? BigDecimal.ZERO : house.getForecastSize();
            // 非公用户进行中断
            if (BigDecimal.ZERO.compareTo(actualSize) == 0 && BigDecimal.ZERO.compareTo(forecastSize) == 0 && house.getPublicFlag() == 0) {
                throw new ServiceException("房屋编号：" + house.getHouseCode() + "现房面积和期房面积均为空，无法计算！");
            }
            if (ArrayUtils.contains(depositSizeType, shareEquallyMoneyRequest.getStandardType())) {
                // 按实际面积取值(实测面积)
                if (1 == standardType) {
                    // depositSize = StringUtils.isNull(house.getActualSize()) ? BigDecimal.ZERO :
                    // house.getActualSize();
                    // 优先判断现房面积
                    depositSize = BigDecimal.ZERO.compareTo(actualSize) == 0 ? forecastSize : actualSize;
                }
                // 按预期面积取值(预测面积)
                if (2 == standardType) {

                    // depositSize = StringUtils.isNull(house.getForecastSize()) ? BigDecimal.ZERO :
                    // house.getForecastSize();
                    // 优先判断期房面积
                    depositSize = BigDecimal.ZERO.compareTo(forecastSize) == 0 ? actualSize : forecastSize;
                }
                allocationMoney = NumberUtil.mul(NumberUtil.div(depositSize, maintenanceFundsBusinessInfo.getTotalInvolvedArea()), maintenanceFundsBusinessInfo.getProjectBudgetAmount());
                house.setAllocationMoney(allocationMoney);

            }
            // 按户数计算公式:分摊金额/户数,截取小数点后两位,剩下的进行补差额
            if (ObjectUtil.equal(3, shareEquallyMoneyRequest.getStandardType())) {
                allocationMoney = NumberUtil.div(maintenanceFundsBusinessInfo.getProjectBudgetAmount(), maintenanceFundsBusinessInfo.getTotalHouseholds(), 2, RoundingMode.HALF_UP);
                house.setAllocationMoney(allocationMoney);
                // 按户优先现房
                depositSize = BigDecimal.ZERO.compareTo(actualSize) == 0 ? forecastSize : actualSize;
            }
            // 设置缴款面积
            allocationMoney.setScale(2, RoundingMode.HALF_UP);
            house.setDepositSize(depositSize);
            house.setTotalAllocationMoney(allocationMoney);
            house.setActualAllocationMoney(allocationMoney);
            // 20230726 判断余额是否不足,余额小于实际分摊金额进行提示
            BigDecimal currentMoney = house.getCurrentMoney();
            if (currentMoney.compareTo(allocationMoney) == -1) {
                sb.append("房屋编号：").append(house.getHouseCode()).append("，实际分摊金额[").append(house.getActualAllocationMoney()).append("]").append("大于可用余额[").append(currentMoney).append("]").append("\n\r");
            }
            totalAllocationMoney.set(totalAllocationMoney.get().add(allocationMoney).setScale(2, RoundingMode.HALF_UP));
            // totalAllocationMoney.set(NumberUtil.add(totalAllocationMoney.get(), allocationMoney));
        });
        // 20230726 查询是否存在提示信息
        if (StringUtils.isNotEmpty(sb) || sb.length() > 0) {
            throw new ServiceException(sb.toString());
        }
        Optional.ofNullable(gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfoByBusinessId(new GwjMaintenanceFundsBusinessInfo() {
            {
                setActualAllocationAmount(totalAllocationMoney.get());
                setBizId(maintenanceFundsBusinessInfo.getBizId());
                setCalculationStandard(shareEquallyMoneyRequest.getStandardType());
            }
        })).<ServiceException>orElseThrow(() -> {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.SHARE_EQUALLY_MONEY) + "GwjMaintenanceFundsBusinessInfo更新失败");
        });
        return gwjMaintenanceFundsBusinessHouseService.updateBatchGwjMaintenanceFundsBusinessHouse(maintenanceFundsBusinessHouseList);
    }

    /**
     * 小区业主信息管理 查询小区列表
     *
     * @param communityListRequest 查询条件
     * @return List<GwjMaintenanceFundsBusinessCommunityDTO> 结果列表
     */
    @Override
    public List<GwjBaseCommunity> selectCommunityList(GwjMaintenanceFundsCommunityListRequest communityListRequest) {
        GwjBaseCommunity gwjBaseCommunity = new GwjBaseCommunity() {
            {
                setCommunityName(communityListRequest.getCommunityName());
                setAreaId(communityListRequest.getAreaId());
            }
        };
        return maintenanceFundsBusinessInnerService.selectCommunityList(gwjBaseCommunity);
    }

    /**
     * 小区业主信息管理 查询业主及其房屋信息列表
     *
     * @param houseOwnerListRequest 查询条件
     * @return List<GwjMaintenanceFundsBusinessCommunityDTO> 结果列表
     */
    @Override
    public List<GwjHouseOwnerListDTO> selectHouseOwnerList(GwjHouseOwnerListRequest houseOwnerListRequest) {
        return maintenanceFundsBusinessInnerService.selectHouseAndOwnerList(houseOwnerListRequest);
    }

    @ConfStepConfigCheck(bizId = "#shareEquallyMoneyRequest.bizId", stepConfigInfo = {StepConfigInfoEnum.SAVE}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int shareEquallyMoneyUpdate(ShareEquallyMoneyRequest shareEquallyMoneyRequest) {
        GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(shareEquallyMoneyRequest.getBizId());
        if (ObjectUtil.isNull(maintenanceFundsBusinessInfo)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_SHARE_EQUALLY_MONEY) + "GwjMaintenanceFundsBusinessInfo为空");
        }
        GwjMaintenanceFundsBusinessHouse maintenanceFundsBusinessHouse = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseByBusinessHouseId(shareEquallyMoneyRequest.getBusinessHouseId());
        GwjMaintenanceFundsBusinessHouse businessHouse = new GwjMaintenanceFundsBusinessHouse();
        businessHouse.setBusinessHouseId(shareEquallyMoneyRequest.getBusinessHouseId());

        // 实际分摊金额=差额+应分摊金额
        if (ObjectUtil.isNotNull(shareEquallyMoneyRequest.getLackMoney())) {
            businessHouse.setLackMoney(shareEquallyMoneyRequest.getLackMoney());
            businessHouse.setActualAllocationMoney(NumberUtil.add(maintenanceFundsBusinessHouse.getAllocationMoney(), shareEquallyMoneyRequest.getLackMoney()));
            businessHouse.setTotalAllocationMoney(NumberUtil.add(maintenanceFundsBusinessHouse.getAllocationMoney(), shareEquallyMoneyRequest.getLackMoney(), shareEquallyMoneyRequest.getSelfRaiseMoney()));
            if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessHouseService.updateGwjMaintenanceFundsBusinessHouse(businessHouse), FlagStatusEnum.SUC.getCode())) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_SHARE_EQUALLY_MONEY) + "GwjMaintenanceFundsBusinessHouse更新失败");
            }
            if (ObjectUtil.equal(gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfo(new GwjMaintenanceFundsBusinessInfo() {
                {
                    setBizId(shareEquallyMoneyRequest.getBizId());
                    List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new GwjMaintenanceFundsBusinessHouse() {
                        {
                            setBizId(shareEquallyMoneyRequest.getBizId());
                            setSelectFlag(SelectFlagEnum.SELECT.getCode());
                        }
                    });
                    BigDecimal actualAllocationAmount = maintenanceFundsBusinessHouseList.stream().map(house -> house.getActualAllocationMoney()).reduce(BigDecimal.ZERO, BigDecimal::add);
                    setActualAllocationAmount(actualAllocationAmount);
                    setTotalAllocatedSettlementAmount(actualAllocationAmount);
                }
            }), FlagStatusEnum.FAL.getCode())) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_SHARE_EQUALLY_MONEY) + "GwjMaintenanceFundsBusinessHouse更新失败");
            }
        }
        // 本次分摊总金额=差额+应分摊金额+自筹金额
        if (ObjectUtil.isNotNull(shareEquallyMoneyRequest.getSelfRaiseMoney())) {
            businessHouse.setSelfRaiseMoney(shareEquallyMoneyRequest.getSelfRaiseMoney());
            businessHouse.setTotalAllocationMoney(NumberUtil.add(maintenanceFundsBusinessHouse.getAllocationMoney(), shareEquallyMoneyRequest.getLackMoney(), shareEquallyMoneyRequest.getSelfRaiseMoney()));
            if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessHouseService.updateGwjMaintenanceFundsBusinessHouse(businessHouse), FlagStatusEnum.SUC.getCode())) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_SHARE_EQUALLY_MONEY) + "GwjMaintenanceFundsBusinessHouse更新失败");
            }
        }
        return FlagStatusEnum.SUC.getCode();
    }

    @ConfStepConfigCheck(bizId = "#allocatedAmountRequest.bizId", stepConfigInfo = {StepConfigInfoEnum.SAVE}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int allocatedAmountArrange(AllocatedAmountRequest allocatedAmountRequest) {
        List<Long> houseIds = allocatedAmountRequest.getHouseIds();
        if (CollectionUtil.isEmpty(houseIds)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) + "List<GwjMaintenanceFundsBusinessHouse>为空");
        }
        List<GwjMaintenanceFundsBusinessHouse> sltMaintenanceFundsBusinessHouseList = ListUtil.toList();
        houseIds.forEach(house -> {
            sltMaintenanceFundsBusinessHouseList.add(new GwjMaintenanceFundsBusinessHouse() {
                {
                    setBusinessHouseId(house);
                    setSelectFlag(SelectFlagEnum.SELECT.getCode());
                }
            });
        });
        if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessHouseService.updateBatchGwjMaintenanceFundsBusinessHouse(sltMaintenanceFundsBusinessHouseList), FlagStatusEnum.SUC.getCode())) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_SELECT) + "GwjMaintenanceFundsBusinessHouse更新失败");
        }

        gwjMaintenanceFundsBusinessHouseService.updateGwjMaintenanceFundsBusinessHouse(new GwjMaintenanceFundsBusinessHouse() {
            {
                setBizId(allocatedAmountRequest.getBizId());
                setLackMoney(BigDecimal.ZERO);
                setUsedMoney(BigDecimal.ZERO);
                setSelfRaiseMoney(BigDecimal.ZERO);
                setTotalAllocationMoney(BigDecimal.ZERO);
                setActualAllocationMoney(BigDecimal.ZERO);
                setAllocationMoney(BigDecimal.ZERO);
            }
        });

        List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new GwjMaintenanceFundsBusinessHouse() {
            {
                setBizId(allocatedAmountRequest.getBizId());
                setSelectFlag(FlagStatusEnum.SUC.getCode());
            }
        });
        Optional.ofNullable(gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfoByBusinessId(new GwjMaintenanceFundsBusinessInfo() {
            {
                setBizId(allocatedAmountRequest.getBizId());
                setTotalHouseholds(maintenanceFundsBusinessHouseList.size());
                BigDecimal totalInvolvedArea = maintenanceFundsBusinessHouseList.stream().map((house) -> {
                    if (ObjectUtil.equal(house.getActualSize(), BigDecimal.ZERO)) {
                        return house.getForecastSize();
                    } else {
                        return house.getActualSize();
                    }
                }).reduce(BigDecimal.ZERO, BigDecimal::add);
                setTotalInvolvedArea(totalInvolvedArea);
            }
        })).<ServiceException>orElseThrow(() -> {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_CANCEL) + "GwjMaintenanceFundsBusinessInfo更新失败");
        });
        return FlagStatusEnum.SUC.getCode();
    }

    @ConfStepConfigCheck(bizId = "#allocatedAmountCancelRequest.bizId", stepConfigInfo = {StepConfigInfoEnum.SAVE}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int allocatedAmountCancel(AllocatedAmountRequest allocatedAmountCancelRequest) {
        List<Long> houseIds = allocatedAmountCancelRequest.getHouseIds();
        if (CollectionUtil.isEmpty(houseIds)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_CANCEL) + "List<GwjMaintenanceFundsBusinessHouse>为空");
        }
        List<GwjMaintenanceFundsBusinessHouse> noMaintenanceFundsBusinessHouseList = ListUtil.toList();
        houseIds.forEach(house -> {
            noMaintenanceFundsBusinessHouseList.add(new GwjMaintenanceFundsBusinessHouse() {
                {
                    setBusinessHouseId(house);
                    setLackMoney(BigDecimal.ZERO);
                    setUsedMoney(BigDecimal.ZERO);
                    setSelfRaiseMoney(BigDecimal.ZERO);
                    setTotalAllocationMoney(BigDecimal.ZERO);
                    setActualAllocationMoney(BigDecimal.ZERO);
                    setAllocationMoney(BigDecimal.ZERO);
                    setSelectFlag(SelectFlagEnum.NO_SELECT.getCode());
                }
            });
        });
        if (ObjectUtil.equal(gwjMaintenanceFundsBusinessHouseService.updateBatchGwjMaintenanceFundsBusinessHouse(noMaintenanceFundsBusinessHouseList), FlagStatusEnum.FAL.getCode())) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_CANCEL) + "List<GwjMaintenanceFundsBusinessHouse>更新失败");
        }

        gwjMaintenanceFundsBusinessHouseService.updateGwjMaintenanceFundsBusinessHouse(new GwjMaintenanceFundsBusinessHouse() {
            {
                setBizId(allocatedAmountCancelRequest.getBizId());
                setLackMoney(BigDecimal.ZERO);
                setUsedMoney(BigDecimal.ZERO);
                setSelfRaiseMoney(BigDecimal.ZERO);
                setTotalAllocationMoney(BigDecimal.ZERO);
                setActualAllocationMoney(BigDecimal.ZERO);
                setAllocationMoney(BigDecimal.ZERO);
            }
        });

        List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new GwjMaintenanceFundsBusinessHouse() {
            {
                setBizId(allocatedAmountCancelRequest.getBizId());
                setSelectFlag(FlagStatusEnum.SUC.getCode());
            }
        });
        Optional.ofNullable(gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfoByBusinessId(new GwjMaintenanceFundsBusinessInfo() {
            {
                setBizId(allocatedAmountCancelRequest.getBizId());
                setTotalHouseholds(maintenanceFundsBusinessHouseList.size());
                BigDecimal totalInvolvedArea = maintenanceFundsBusinessHouseList.stream().map((house) -> {
                    if (ObjectUtil.equal(house.getActualSize(), BigDecimal.ZERO)) {
                        return house.getForecastSize();
                    } else {
                        return house.getActualSize();
                    }
                }).reduce(BigDecimal.ZERO, BigDecimal::add);
                setTotalInvolvedArea(totalInvolvedArea);
                // 20230816 实际分摊金额归0
                setActualAllocationAmount(BigDecimal.ZERO);
            }
        })).<ServiceException>orElseThrow(() -> {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ALLOCATED_AMOUNT_CANCEL) + "GwjMaintenanceFundsBusinessInfo更新失败");
        });
        return FlagStatusEnum.SUC.getCode();
    }

    /**
     * 保存业务 更改公维金使用资金申请业务
     *
     * @param gwjMaintenanceFundsBusinessAddRequest gwj维修基金业务请求
     * @return int
     */
    @ConfStepConfigCheck(bizId = "#gwjMaintenanceFundsBusinessAddRequest.bizId", stepConfigInfo = {StepConfigInfoEnum.SAVE}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int editMaintenanceFundsBusinessForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest) {
        if (ObjectUtil.equal(gwjMaintenanceFundsBusinessAddRequest.getAppropriationWay(), BusinessTypeEnum.PREPARE.getCode())) {
            gwjMaintenanceFundsBusinessAddRequest.setBudgetAppropriationAmount(BigDecimal.ZERO);
        } else {
            int compareTo = gwjMaintenanceFundsBusinessAddRequest.getBudgetAppropriationAmount().compareTo(gwjMaintenanceFundsBusinessAddRequest.getProjectBudgetAmount());
            if (compareTo > 0) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "预算拨出金额必须小于等于工程预算");
            }
            int compare = gwjMaintenanceFundsBusinessAddRequest.getBudgetAppropriationAmount().compareTo(BigDecimal.ZERO);
            if (compare < 0) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "预算拨出金额必须大于等于工程预算");
            }
        }
        // 1.更改business表d
        GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness = new GwjMaintenanceFundsBusiness() {
            {
                setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                setContacts(gwjMaintenanceFundsBusinessAddRequest.getContacts());
                setPhone(gwjMaintenanceFundsBusinessAddRequest.getPhone());
                setBizName(gwjMaintenanceFundsBusinessAddRequest.getBizName());
                setAddress(gwjMaintenanceFundsBusinessAddRequest.getAddress());
                setCompletedTime(gwjMaintenanceFundsBusinessAddRequest.getCompletedTime());
                setValidDate(gwjMaintenanceFundsBusinessAddRequest.getValidDate());
            }
        };
        if (ObjectUtil.isNull(((IGwjMaintenanceFundsBusinessService)AopContext.currentProxy()).updateGwjMaintenanceFundsBusiness(gwjMaintenanceFundsBusiness))) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "GwjMaintenanceFundsBusiness更新失败");
        }
        try {
            // 2.更改community表
            editCommunityForm(gwjMaintenanceFundsBusinessAddRequest);
            // 判断是否更改了楼栋
            List<GwjMaintenanceFundsBusinessBuild> gwjMaintenanceFundsBusinessBuilds = gwjMaintenanceFundsBusinessBuildService.selectGwjMaintenanceFundsBusinessBuildByBusinessId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
            List<String> buildCodeCollect = gwjMaintenanceFundsBusinessBuilds.stream().map(GwjMaintenanceFundsBusinessBuild::getBuildCode).collect(Collectors.toList());
            List<String> buildCodeList = gwjMaintenanceFundsBusinessAddRequest.getBuilds().stream().map(GwjMaintenanceFundsBusinessAddRequest.Build::getBuildCode).collect(Collectors.toList());
            if (!CheckDiffList.checkDifferent(buildCodeCollect, buildCodeList)) {
                // 3.更改楼栋信息
                int deleteBuildFlag = gwjMaintenanceFundsBusinessBuildService.deleteGwjMaintenanceFundsBusinessBuildByBusinessId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                if (ObjectUtil.equal(deleteBuildFlag, FlagStatusEnum.FAL.getCode())) {
                    throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "楼栋删除失败");
                }
                editBuildForm(gwjMaintenanceFundsBusinessAddRequest);
                // 4.更新house表
                int deleteHouseFlag = gwjMaintenanceFundsBusinessHouseService.deleteGwjMaintenanceFundsBusinessHouseByBusinessId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                if (ObjectUtil.equal(deleteHouseFlag, FlagStatusEnum.FAL.getCode())) {
                    throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "房屋删除失败");
                }
                List<GwjInsertHouseRequest> baseHouseList = editHouseForm(gwjMaintenanceFundsBusinessAddRequest);
                // 5.更改owner表
                int deleteOwnerFlag = gwjMaintenanceFundsBusinessOwnerService.deleteGwjMaintenanceFundsBusinessOwnerByBusinessId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                if (ObjectUtil.equal(deleteOwnerFlag, FlagStatusEnum.FAL.getCode())) {
                    throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "GwjMaintenanceFundsBusinessOwner删除失败");
                }
                editOwnerForm(gwjMaintenanceFundsBusinessAddRequest, baseHouseList);
            }
            // 6.更改info表
            editInfoForm(gwjMaintenanceFundsBusinessAddRequest);
        } catch (Exception e) {
            if (log.isDebugEnabled()) {
                log.debug("更新使用申请表信息异常 -> [{}]", e);
            }
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "更新使用申请表信息异常");
        }
        return FlagStatusEnum.SUC.getCode();
    }

    public void editOwnerForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest, List<GwjInsertHouseRequest> baseHouseList) {
        List<GwjMaintenanceFundsBusinessOwner> maintenanceFundsBusinessOwnersList = new ArrayList<GwjMaintenanceFundsBusinessOwner>();
        List<String> houseCodeList = baseHouseList.stream().map(GwjInsertHouseRequest::getHouseCode).collect(Collectors.toList());
        String[] houseCodes = ArrayUtil.toArray(houseCodeList, String.class);
        List<GwjBaseOwner> baseOwnerList = maintenanceFundsBusinessInnerService.selectGwjBaseListByGwjBaseHouseCodes(houseCodes, gwjMaintenanceFundsBusinessAddRequest.getAreaId());
        // 20230621 hmh
        // 注：baseOwnerList查询房屋内如果没有任何业主，这里会导致业务过不去
        // 修订：可以存在有房屋无业主情况，暂时将其放过不进行校验！start
        if (CollectionUtil.isEmpty(baseOwnerList)) {
            // throw new
            // ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) +
            // "公维金获取基础业主信息失败");
            return;
        }
        // end
        // if (CollectionUtil.isEmpty(baseOwnerList)) {
        // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) +
        // "公维金获取基础业主信息失败");
        // }
        baseOwnerList.forEach(baseOwner -> {
            maintenanceFundsBusinessOwnersList.add(new GwjMaintenanceFundsBusinessOwner() {
                {
                    setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                    setPhone(baseOwner.getOwnerPhone());
                    setCardNum(baseOwner.getCardNum());
                    setOwnerName(baseOwner.getOwnerName());
                    setHouseCode(baseOwner.getHouseCode());
                    setCreateTime(DateUtils.getNowDate());
                    // 20230621 新增创建人
                    setCreateBy(SecurityUtils.getUsername());
                }
            });
        });
        if (gwjMaintenanceFundsBusinessOwnerService.insertBatchGwjMaintenanceFundsBusinessOwner(maintenanceFundsBusinessOwnersList) == FlagStatusEnum.FAL.getCode()) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "新增公维金资金申请业主信息失败");
        }
    }

    public void editCommunityForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest) {
        GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity = new GwjMaintenanceFundsBusinessCommunity() {
            {
                setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                setDevelopmentEnterpriseName(gwjMaintenanceFundsBusinessAddRequest.getDevelopmentEnterpriseName());
                setOwnerCommitteeName(gwjMaintenanceFundsBusinessAddRequest.getOwnerCommitteeName());
            }
        };
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusinessCommunityService.updateGwjMaintenanceFundsBusinessCommunityByBusinessId(gwjMaintenanceFundsBusinessCommunity))) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "更新公维金资金申请社区信息失败");
        }
    }

    public void editBuildForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest) {
        List<GwjMaintenanceFundsBusinessAddRequest.Build> builds = gwjMaintenanceFundsBusinessAddRequest.getBuilds();
        ArrayList<GwjMaintenanceFundsBusinessBuild> gwjMaintenanceFundsBusinessBuilds = new ArrayList<GwjMaintenanceFundsBusinessBuild>();
        for (GwjMaintenanceFundsBusinessAddRequest.Build build : builds) {
            Long buildId = build.getBuildId();
            GwjBaseBuild gwjBaseBuild = maintenanceFundsBusinessInnerService.selectGwjBaseBuildByBuildId(buildId);
            if (ObjectUtil.isNull(gwjBaseBuild)) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "获取基础楼栋信息失败");
            }
            GwjMaintenanceFundsBusinessBuild gwjMaintenanceFundsBusinessBuild = new GwjMaintenanceFundsBusinessBuild() {
                {
                    setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                    setBuildId(gwjBaseBuild.getBuildId());
                    setBuildName(gwjBaseBuild.getBuildName());
                    setTotalSize(gwjBaseBuild.getTotalSize());
                    setPeriodSize(gwjBaseBuild.getPeriodSize());
                    setTotalOwner(gwjBaseBuild.getTotalOwner());
                    setTotalLayer(gwjBaseBuild.getTotalLayer());
                    setResidence(gwjBaseBuild.getResidence());
                    setNonResidence(gwjBaseBuild.getNonResidence());
                    setAreaId(gwjBaseBuild.getAreaId());
                    setStreetId(gwjBaseBuild.getStreetId());
                    setCommunityId(gwjMaintenanceFundsBusinessAddRequest.getCommunityId());
                    setBuildCode(gwjBaseBuild.getBuildCode());
                    setBuildNo(gwjBaseBuild.getBuildNo());
                    setBuildType(gwjBaseBuild.getBuildType());
                    setCreateTime(DateUtils.getNowDate());
                }
            };
            gwjMaintenanceFundsBusinessBuilds.add(gwjMaintenanceFundsBusinessBuild);
        }
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusinessBuildService.insertBatchGwjMaintenanceFundsBusinessBuild(gwjMaintenanceFundsBusinessBuilds))) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "更新公维金资金申请建筑信息失败");
        }
    }

    public List<GwjInsertHouseRequest> editHouseForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest) {
        List<GwjMaintenanceFundsBusinessAddRequest.Build> builds = gwjMaintenanceFundsBusinessAddRequest.getBuilds();
        List<GwjInsertHouseRequest> gwjInsertHouseRequests = new ArrayList<GwjInsertHouseRequest>();
        for (int i = 0; i < builds.size(); i++) {
            int finalI = i;
            GwjBaseHouse gwjBaseHouse = new GwjBaseHouse() {
                {
                    setBuildCode(builds.get(finalI).getBuildCode());
                    setAreaId(gwjMaintenanceFundsBusinessAddRequest.getAreaId());
                }
            };
            List<GwjBaseHouse> gwjBaseHousesList = maintenanceFundsBusinessInnerService.selectGwjBaseHouseList(gwjBaseHouse);

            if (CollectionUtil.isEmpty(gwjBaseHousesList)) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "获取公维金资金申请基础房屋信息失败");
            }
            List<GwjInsertHouseRequest> insertHouseRequestsList = BeanUtil.copyToList(gwjBaseHousesList, GwjInsertHouseRequest.class);
            insertHouseRequestsList.forEach(insertHouse -> {
                insertHouse.setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                insertHouse.setAvailableMoney(insertHouse.getCurrentMoney().subtract(insertHouse.getBlockedMoney()));
            });
            gwjInsertHouseRequests.addAll(insertHouseRequestsList);
        }
        if (gwjMaintenanceFundsBusinessHouseService.insertGwjMaintenanceFundsBusinessHouseList(gwjInsertHouseRequests) == FlagStatusEnum.FAL.getCode()) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.ADD_USE_APPLY_FAL) + "新增公维金资金申请房屋信息失败");
        }
        return gwjInsertHouseRequests;
    }

    public void editInfoForm(GwjMaintenanceFundsBusinessAddRequest gwjMaintenanceFundsBusinessAddRequest) {
        BigDecimal totalArea = new BigDecimal(0);
        List<GwjMaintenanceFundsBusinessHouse> gwjMaintenanceFundsBusinessHouseList = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new GwjMaintenanceFundsBusinessHouse() {
            {
                setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
            }
        });
        for (GwjMaintenanceFundsBusinessHouse house : gwjMaintenanceFundsBusinessHouseList) {
            if (ObjectUtil.equals(house.getActualSize(), BigDecimal.ZERO)) {
                totalArea = totalArea.add(house.getForecastSize());
            } else {
                totalArea = totalArea.add(house.getActualSize());
            }
        }
        BigDecimal finalTotalArea = totalArea;
        GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo = new GwjMaintenanceFundsBusinessInfo() {
            {
                setBizId(gwjMaintenanceFundsBusinessAddRequest.getBizId());
                setMaintenanceItems(gwjMaintenanceFundsBusinessAddRequest.getMaintenanceItems());
                setMaintenanceReason(gwjMaintenanceFundsBusinessAddRequest.getMaintenanceReason());
                setDeclarationDate(gwjMaintenanceFundsBusinessAddRequest.getDeclarationDate());
                setProjectBudgetAmount(gwjMaintenanceFundsBusinessAddRequest.getProjectBudgetAmount());
                setAppropriationWay(gwjMaintenanceFundsBusinessAddRequest.getAppropriationWay());
                setBudgetAppropriationAmount(gwjMaintenanceFundsBusinessAddRequest.getBudgetAppropriationAmount());
                setConstructionUnit(gwjMaintenanceFundsBusinessAddRequest.getConstructionUnit());
                setPayeeName(gwjMaintenanceFundsBusinessAddRequest.getPayeeName());
                setBankDeposit(gwjMaintenanceFundsBusinessAddRequest.getBankDeposit());
                setCollectionAccount(gwjMaintenanceFundsBusinessAddRequest.getCollectionAccount());
                setTotalHouseholds(gwjMaintenanceFundsBusinessHouseList.size());
                setTotalInvolvedArea(finalTotalArea);
                setAcceptancePlan(gwjMaintenanceFundsBusinessAddRequest.getAcceptancePlan());
                setApplicationUnitName(gwjMaintenanceFundsBusinessAddRequest.getApplicationUnitName());
                // 20230710 hmh 新增
                setBankId(gwjMaintenanceFundsBusinessAddRequest.getBankId());
            }
        };
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfoByBusinessId(gwjMaintenanceFundsBusinessInfo))) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.UPDATE_USE_APPLY_FAL) + "GwjMaintenanceFundsBusinessInfo更新失败");
        }
    }

    @Override
    public ApplicationReportDTO getApplicationReport(Long bizId) {
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_APPLICATION_REPORT) + "GwjMaintenanceFundsBusiness为空");
        }
        GwjMaintenanceFundsBusinessCommunity maintenanceFundsBusinessCommunity = gwjMaintenanceFundsBusinessCommunityService.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(bizId);
        GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(bizId);

        GwjMaintenanceFundsBusinessAttachment maintenanceFundsBusinessAttachment = maintenanceFundsBusinessAttachmentService.getGwjMaintenanceFundsBusinessAttachment(new GwjMaintenanceFundsBusinessAttachment() {
            {
                setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
                setServerType(BusinessAttachmentServerTypeEnum.APPLICATION_REPORT.getCode());
                setType(BusinessAttachmentTypeEnum.REPORT.getCode());
            }
        });
        return new ApplicationReportDTO() {
            {
                setAddress(maintenanceFundsBusiness.getAddress());
                setApplyName(maintenanceFundsBusiness.getApplicantUserName());
                setCommunityName(maintenanceFundsBusinessCommunity.getCommunityName());
                setDevelopmentEnterpriseName(maintenanceFundsBusinessCommunity.getDevelopmentEnterpriseName());
                setCompletedTime(maintenanceFundsBusiness.getCompletedTime());
                setTotalBuild(maintenanceFundsBusinessCommunity.getTotalBuild());
                setTotalSize(maintenanceFundsBusinessCommunity.getTotalSize());
                setTotalOwner(maintenanceFundsBusinessCommunity.getTotalOwner());
                setMaintenanceItems(maintenanceFundsBusinessInfo.getMaintenanceItems());
                setMaintenanceReason(maintenanceFundsBusinessInfo.getMaintenanceReason());
                setProjectBudgetAmount(maintenanceFundsBusinessInfo.getProjectBudgetAmount());
                setApplicationUnitName(maintenanceFundsBusinessInfo.getApplicationUnitName());
                if (ObjectUtil.isNotNull(maintenanceFundsBusinessAttachment)) {
                    setAttachmentId(maintenanceFundsBusinessAttachment.getAttachmentId());
                    ApplicationReportRequest applicationReport = JSONUtil.toBean(maintenanceFundsBusinessAttachment.getContent(), ApplicationReportRequest.class);
                    setCompletionTime(applicationReport.getCompletedTime());
                    setPublicityStartTime(applicationReport.getPublicityStartTime());
                    setPublicityEndTime(applicationReport.getPublicityEndTime());
                    setPositionInformation(applicationReport.getPositionInformation());
                    setSignTime(applicationReport.getSignTime());
                    setExploredOwnerNumber(applicationReport.getExploredOwnerNumber());
                }
            }
        };
    }

    // @Override
    // public OwnerCommentsDTO getOwnerComments(Long bizId) {
    // GwjMaintenanceFundsBusiness maintenanceFundsBusiness =
    // gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
    // if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
    // throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_APPLICATION_REPORT) +
    // "GwjMaintenanceFundsBusiness为空");
    // }
    // List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList =
    // gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new
    // GwjMaintenanceFundsBusinessHouse() {
    // /**
    // *
    // */
    // private static final long serialVersionUID = -2483494641438426430L;
    //
    // {
    // setBizId(getBizId());
    // }
    // });
    // GwjMaintenanceFundsBusinessCommunity maintenanceFundsBusinessCommunity =
    // gwjMaintenanceFundsBusinessCommunityService.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(bizId);
    // GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo =
    // gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(bizId);
    // return new OwnerCommentsDTO() {
    // {
    // setApplyName(maintenanceFundsBusiness.getApplicantUserName());
    // setCommunityName(maintenanceFundsBusinessCommunity.getCommunityName());
    // setMaintenanceItems(maintenanceFundsBusinessInfo.getMaintenanceItems());
    // setProjectBudgetAmount(maintenanceFundsBusinessInfo.getProjectBudgetAmount());
    // setTableDataInfo(PageUtils.getDataTable(maintenanceFundsBusinessHouseList));
    // }
    // };
    // }

    @Override
    public OwnerCommentsDTO getOwnerComments(Long bizId) {
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            // throw new
            // ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_APPLICATION_REPORT) +
            // "GwjMaintenanceFundsBusiness为空");
            throw new ServiceException("未获取到对应业务信息！");
        }
        // List<GwjMaintenanceFundsBusinessHouse> maintenanceFundsBusinessHouseList =
        // gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new
        // GwjMaintenanceFundsBusinessHouse() {
        //
        // {
        // setBizId(getBizId());
        // }
        // });
        // 开启分页
        PageUtils.startPage();
        // 获取投票结果
        List<GwjExpendHouseAndOwnerDTO> voteList = gwjExpendOutsideBaseHouseService.selectHouseAndOwnerVoteInfosByBizIdAndBizNum(bizId, maintenanceFundsBusiness.getBizNum());
        GwjMaintenanceFundsBusinessCommunity maintenanceFundsBusinessCommunity = gwjMaintenanceFundsBusinessCommunityService.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(bizId);
        GwjMaintenanceFundsBusinessInfo maintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(bizId);
        return new OwnerCommentsDTO() {
            {
                setApplyName(maintenanceFundsBusiness.getApplicantUserName());
                setCommunityName(maintenanceFundsBusinessCommunity.getCommunityName());
                setMaintenanceItems(maintenanceFundsBusinessInfo.getMaintenanceItems());
                setProjectBudgetAmount(maintenanceFundsBusinessInfo.getProjectBudgetAmount());
                setTableDataInfo(PageUtils.getDataTable(voteList));
            }
        };
    }

    /**
     * 获取改造方案
     *
     * @param bizId 业务标识
     * @return {@link ChangeSchemeDTO}
     */
    @Override
    public ChangeSchemeDTO getTransformationPlan(Long bizId) {
        GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness = selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusiness)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_CHANGE_SCHEME) + "GwjMaintenanceFundsBusiness为空");
        }
        GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity = gwjMaintenanceFundsBusinessCommunityService.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(bizId);
        GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(bizId);

        GwjMaintenanceFundsBusinessAttachment maintenanceFundsBusinessAttachment = maintenanceFundsBusinessAttachmentService.getGwjMaintenanceFundsBusinessAttachment(new GwjMaintenanceFundsBusinessAttachment() {
            {
                setServerIdentification(gwjMaintenanceFundsBusiness.getServerIdentification());
                setServerType(BusinessAttachmentServerTypeEnum.TRANSFORMATION_PLAN.getCode());
                setType(BusinessAttachmentTypeEnum.REPORT.getCode());
            }
        });
        List<GwjMaintenanceFundsBusinessBuild> gwjMaintenanceFundsBusinessBuilds = gwjMaintenanceFundsBusinessBuildService.selectGwjMaintenanceFundsBusinessBuildByBusinessId(bizId);
        StringBuffer buildNameString = new StringBuffer();
        gwjMaintenanceFundsBusinessBuilds.forEach(build -> buildNameString.append(build.getBuildName().concat("，")));
        buildNameString.deleteCharAt(buildNameString.length() - 1);
        return new ChangeSchemeDTO() {
            {
                setCompletedTimeYear(DateUtil.year(gwjMaintenanceFundsBusiness.getCompletedTime()));
                setCompletedTimeMouth(DateUtil.month(gwjMaintenanceFundsBusiness.getCompletedTime()) + 1);
                setCommunityName(gwjMaintenanceFundsBusinessCommunity.getCommunityName());
                setDevelopmentEnterpriseName(gwjMaintenanceFundsBusinessCommunity.getDevelopmentEnterpriseName());
                setCommunityLocation(gwjMaintenanceFundsBusinessCommunity.getCommunityLocation());
                setTotalSize(gwjMaintenanceFundsBusinessCommunity.getTotalSize());
                setTotalOwner(gwjMaintenanceFundsBusinessCommunity.getTotalOwner());
                setTotalBuild(gwjMaintenanceFundsBusinessCommunity.getTotalBuild());
                setMaintenanceItems(gwjMaintenanceFundsBusinessInfo.getMaintenanceItems());
                setMaintenanceReason(gwjMaintenanceFundsBusinessInfo.getMaintenanceReason());
                setConstructionUnit(gwjMaintenanceFundsBusinessInfo.getConstructionUnit());
                setProjectBudgetAmount(gwjMaintenanceFundsBusinessInfo.getProjectBudgetAmount());
                setFullNameOfPayee(gwjMaintenanceFundsBusinessInfo.getPayeeName());
                setBankDeposit(gwjMaintenanceFundsBusinessInfo.getBankDeposit());
                setCollectionAccount(gwjMaintenanceFundsBusinessInfo.getCollectionAccount());
                setAcceptancePlan(gwjMaintenanceFundsBusinessInfo.getAcceptancePlan());
                setFullNameOfApplicationUnit(gwjMaintenanceFundsBusinessInfo.getApplicationUnitName());
                setBuildNameList(buildNameString.toString());
                if (ObjectUtil.isNotNull(maintenanceFundsBusinessAttachment)) {
                    setAttachmentId(maintenanceFundsBusinessAttachment.getAttachmentId());
                    GwjSaveChangeSchemeRequest gwjSaveChangeSchemeRequest = JSONUtil.toBean(maintenanceFundsBusinessAttachment.getContent(), GwjSaveChangeSchemeRequest.class);
                    setCostDetail(gwjSaveChangeSchemeRequest.getCostDetail());
                    setCorporateAccount(gwjSaveChangeSchemeRequest.getCorporateAccount());
                    setUpdateDetail(gwjSaveChangeSchemeRequest.getUpdateDetail());
                    setSaveTime(gwjSaveChangeSchemeRequest.getSaveTime());
                }
            }
        };
    }

    /**
     * 获取业主确认证明
     *
     * @param bizId 业务标识
     * @return {@link OwnerCheckProveDTO}
     */
    @Override
    public OwnerCheckProveDTO getOwnerCheckProve(Long bizId) {
        GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness = gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(gwjMaintenanceFundsBusiness)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "GwjMaintenanceFundsBusiness为空");
        }
        GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(bizId);
        GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity = gwjMaintenanceFundsBusinessCommunityService.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(bizId);

        return new OwnerCheckProveDTO() {
            {
                // if (ObjectUtil.isNotEmpty(gwjMaintenanceFundsBusiness.getOwnerConfirmationCertificate())) {
                // SaveOwnerCheckProveRequest saveOwnerCheckProveRequest =
                // JSONUtil.toBean(gwjMaintenanceFundsBusiness.getOwnerConfirmationCertificate(),
                // SaveOwnerCheckProveRequest.class);
                // setChangeYear(saveOwnerCheckProveRequest.getChangeYear());
                // setChangeMonth(saveOwnerCheckProveRequest.getChangeMonth());
                // }
                setCommunityName(gwjMaintenanceFundsBusinessCommunity.getCommunityName());
                setMaintenanceItems(gwjMaintenanceFundsBusinessInfo.getMaintenanceItems());
                setTotalHouseholds(gwjMaintenanceFundsBusinessInfo.getTotalHouseholds());
                setTotalAreaInvolved(gwjMaintenanceFundsBusinessInfo.getTotalInvolvedArea());
                setProjectBudgetAmount(gwjMaintenanceFundsBusinessInfo.getProjectBudgetAmount());
            }
        };
    }

    @ConfStepConfigCheck(bizId = "#bizId", stepConfigInfo = {StepConfigInfoEnum.SUBMIT}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int preAcceptSecondSubmit(Long bizId) {
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "GwjMaintenanceFundsBusiness为空");
        }
        List<GwjMaintenanceFundsBusinessAttachment> maintenanceFundsBusinessAttachmentList = maintenanceFundsBusinessAttachmentService.getGwjMaintenanceFundsBusinessAttachmentList(new GetAttachmentInfoRequest() {
            {
                setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
                setServerTypeList(
                    ListUtil.toList(BusinessAttachmentServerTypeEnum.PUBLICITY_PHOTOS.getCode(), BusinessAttachmentServerTypeEnum.APPLICANT_MATERIALS.getCode(), BusinessAttachmentServerTypeEnum.MAINTENANCE_CONTRACT.getCode(), BusinessAttachmentServerTypeEnum.ADVANCE_PAYMENT_RECEIPT.getCode(), BusinessAttachmentServerTypeEnum.APPLICATION_REPORT.getCode(), BusinessAttachmentServerTypeEnum.OWNER_CONFIRMATION_CERTIFICATE.getCode(), BusinessAttachmentServerTypeEnum.OWNER_COMMENTS.getCode()));
            }
        });
        if (CollectionUtil.isEmpty(maintenanceFundsBusinessAttachmentList)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "二次补件文件信息未上传");
        }
        List<BusinessAttachmentServerTypeEnum> serverTypeEnumList = maintenanceFundsBusinessAttachmentService.checkNull(() -> {
            return Optional.of(maintenanceFundsBusinessAttachmentList);
        }, false, ListUtil.toList(BusinessAttachmentServerTypeEnum.APPLICATION_REPORT, BusinessAttachmentServerTypeEnum.PUBLICITY_PHOTOS, BusinessAttachmentServerTypeEnum.APPLICANT_MATERIALS, BusinessAttachmentServerTypeEnum.MAINTENANCE_CONTRACT, BusinessAttachmentServerTypeEnum.ADVANCE_PAYMENT_RECEIPT));
        if (CollectionUtil.isNotEmpty(serverTypeEnumList)) {
            throw new ServiceException("附件" + serverTypeEnumList.get(0).getInfo() + "未提交,请先上传");
        }
        Optional.ofNullable(((IGwjMaintenanceFundsBusinessService)AopContext.currentProxy()).updateGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusiness() {
            {
                setBizId(bizId);
                setStatus(BusinessStatusEnum.SUBMIT.getCode());
                setServerStatus(BusinessServerStatusEnum.NORMAL.getCode());
            }
        })).<ServiceException>orElseThrow(() -> {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "GwjMaintenanceFundsBusiness更新失败");
        });
        int insertFlag = gwjMaintenanceFundsBusinessLogService.insertGwjMaintenanceFundsBusinessLog(new GwjMaintenanceFundsBusinessLog() {
            {
                setResult(GwjBusinessLogResult.SUBMIT.getCode());
                setBizId(maintenanceFundsBusiness.getBizId());
                setStepId(maintenanceFundsBusiness.getStepId());
            }
        });
        if (ObjectUtil.equal(FlagStatusEnum.FAL.getCode(), insertFlag)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "GwjMaintenanceFundsBusinessLog新增失败");
        }

        PreAcceptSecondSubmitMessage preAcceptSecondSubmitMessage = new PreAcceptSecondSubmitMessage();
        preAcceptSecondSubmitMessage.setBizId(maintenanceFundsBusiness.getBizId());
        preAcceptSecondSubmitMessage.setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
        preAcceptSecondSubmitMessage.setOutServerIdentification(maintenanceFundsBusiness.getOutServerIdentification());
        preAcceptSecondSubmitMessage.setMaintenanceFundsBusinessAttachmentList(maintenanceFundsBusinessAttachmentList);

        // 提交到内网审核
        String tag = maintenanceFundsBusinessConfiguration.tagProperties().getPreAcceptSecondSubmit();
        MqSendResult mqSendResult = mqSendMessageHandler.syncSend(new MaintenanceFundsMqMessageBody() {
            {
                setJsonMsg(JSONUtil.toJsonStr(preAcceptSecondSubmitMessage));
                setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
            }
        }, new MaintenanceFundsBusinessConfiguration.MaintenanceFundsBusinessSendRequest(tag, null));
        if (mqSendResult.isSuccess()) {
            return FlagStatusEnum.SUC.getCode();
        } else {
            log.error("公维金资金申请提交数据到内网MQ异常 -> [{}]", mqSendResult.getMessage());
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "公维金资金申请提交数据到内网MQ异常");
        }
    }

    /**
     * 申请业务时查询回填所需信息
     *
     * @return 申请业务小区信息
     */
    @Override
    public ApplyBaseInfoDTO getCommunity(Long communityId) {
        GwjBaseCommunity gwjBaseCommunity = maintenanceFundsBusinessInnerService.selectGwjBaseCommunityByGwjBaseCommunityId(communityId);
        if (ObjectUtil.isNull(gwjBaseCommunity)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_COMMUNITY_FAL) + "基础小区信息获取失败");
        }
        GwjConfBusinessFlag gwjConfBusinessFlag = remoteGwjConfigService.selectGwjConfBusinessFlagByBizFlagId(businessFlagType.getCode(), SecurityConstants.INNER).getData();
        if (ObjectUtil.isNull(gwjConfBusinessFlag)) {
            return null;
        }
        GwjConfStep confStep;
        try {
            R<List<GwjConfStep>> r = remoteGwjConfigService.selectGwjConfStepListByFlagId(businessFlagType.getCode(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                throw new ServiceException(r.getMsg());
            }
            confStep = r.getData().get(0);
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectGwjConfStepListByFlagId]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_STEP_ID_FAL) + "远程调用 -> [remoteGwjConfigService][selectGwjConfStepListByFlagId]异常");
        }
        return new ApplyBaseInfoDTO() {
            {
                setCommunityName(gwjBaseCommunity.getCommunityName());
                setCompanyName(gwjBaseCommunity.getCompanyName());
                setContacts(SecurityUtils.getLoginUser().getSysOutsideUser().getRealName());
                setPhone(SecurityUtils.getLoginUser().getSysOutsideUser().getPhonenumber());
                setCategory(gwjConfBusinessFlag.getCategory());
                setBizFlagId(gwjConfBusinessFlag.getBizFlagId());
                setFlowId(gwjConfBusinessFlag.getFlowId());
                setFlowName(gwjConfBusinessFlag.getSubcategory());
                setStepId(confStep.getStepId());
                setStepName(confStep.getName());
                setApplicationUnitName(gwjBaseCommunity.getCompanyName());
            }
        };
    }

    /**
     * 获取开发商列表
     *
     * @param companyName 公司名称
     * @return {@link List}<{@link String}>
     */
    @Override
    public List<DeveloperListDTO> getDevelopers(String companyName) {
        GwjBaseCommunity gwjBaseCommunity = new GwjBaseCommunity() {
            {
                setCompanyName(companyName);
            }
        };
        List<GwjBaseCommunity> baseCommunityList = maintenanceFundsBusinessInnerService.selectGwjBaseCommunityList(gwjBaseCommunity);
        if (CollectionUtil.isEmpty(baseCommunityList)) {
            return new ArrayList<DeveloperListDTO>();
        }
        List<String> companyNameList = baseCommunityList.stream().map(GwjBaseCommunity::getCompanyName).collect(Collectors.toList());
        List<DeveloperListDTO> developerListDTO = new ArrayList<DeveloperListDTO>();
        companyNameList.forEach(company -> developerListDTO.add(new DeveloperListDTO() {
            {
                setCompanyName(company);
            }
        }));
        return developerListDTO;
    }

    /**
     * 查询楼栋列表
     *
     * @param buildName 楼栋名称
     * @return {@link List}<{@link GwjBaseBuild}>
     */
    @Override
    public List<GwjBaseBuild> getBuilds(Long communityId, String buildName) {
        return maintenanceFundsBusinessInnerService.selectGwjBaseBuildListByCommunityIdBuildName(new GwjBaseBuild() {
            {
                setCommunityId(communityId);
                setBuildName(buildName);
            }
        });
    }

    /**
     * 根据flowId查询业务流程
     *
     * @param flowId 业务流程主键
     * @return 业务流程
     */
    @Override
    public GwjConfFlow selectGwjConfFlowByFlowId(Long flowId) {
        return gwjMaintenanceFundsBusinessMapper.selectGwjConfFlowByFlowId(flowId);
    }

    @Override
    public GwjMaintenanceFundsBusiness getGwjMaintenanceFundsBusiness(GwjMaintenanceFundsBusinessRequest maintenanceFundsBusinessRequest) {
        return gwjMaintenanceFundsBusinessMapper.getGwjMaintenanceFundsBusiness(maintenanceFundsBusinessRequest);
    }

    /**
     * 查询使用申请基础信息 getUseApplyInfo
     */
    @Override
    public GwjBusinessBaseInfoDTO getUseApplyInfo() {
        GwjBusinessBaseInfoDTO businessBaseInfoDTO = new GwjBusinessBaseInfoDTO();
        try {
            R<GwjConfBusinessFlag> r = remoteGwjConfigService.selectGwjConfBusinessFlagByBizFlagId(businessFlagType.getCode(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                return null;
            }
            businessBaseInfoDTO.setCategory(r.getData().getCategory());
            businessBaseInfoDTO.setBizFlagId(r.getData().getBizFlagId());
            businessBaseInfoDTO.setFlowId(r.getData().getFlowId());
            businessBaseInfoDTO.setFlowName(r.getData().getSubcategory());
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectGwjConfBusinessFlagByBizFlagId]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_USE_APPLY_BASE_INFO_FAL) + "远程调用 -> [remoteGwjConfigService][selectGwjConfBusinessFlagByBizFlagId]异常");
        }
        try {
            R<List<GwjConfStep>> r = remoteGwjConfigService.selectGwjConfStepListByFlagId(businessFlagType.getCode(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                return null;
            }
            businessBaseInfoDTO.setStepId(r.getData().get(0).getStepId());
            businessBaseInfoDTO.setStepName(r.getData().get(0).getName());
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectGwjConfStepListByFlagId]异常,异常信息: [{}]", e);
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_USE_APPLY_BASE_INFO_FAL) + "远程调用 -> [remoteGwjConfigService][selectGwjConfStepListByFlagId]异常");
        }
        return businessBaseInfoDTO;
    }

    /**
     * 获取gwj维修基金业务详细信息
     *
     * @param bizId 业务标识
     * @return {@link GetBusinessDetailDTO}
     */
    @Override
    public GetBusinessDetailDTO getDetailMessage(Long bizId) {
        GetBusinessDetailDTO businessDetailMessage = gwjMaintenanceFundsBusinessMapper.getBusinessDetailMessage(bizId);
        if (ObjectUtil.isNull(businessDetailMessage)) {
            return null;
        }
        try {
            R<GwjConfBusinessFlag> r = remoteGwjConfigService.selectGwjConfBusinessFlagByBizFlagId(businessDetailMessage.getBizFlagId(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                throw new ServiceException(r.getMsg());
            }
            businessDetailMessage.setCategory(r.getData().getCategory());
            businessDetailMessage.setFlowName(r.getData().getSubcategory());
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][selectGwjConfBusinessFlagByBizFlagId]异常,异常信息: [{}]", e);
            return null;
        }
        try {
            R<GwjConfStep> r = remoteGwjConfigService.selectByConfStepId(businessDetailMessage.getStepId(), SecurityConstants.INNER);
            if (R.isError(r)) {
                throw new ServiceException(r.getMsg());
            }
            if (ObjectUtil.isNull(r.getData())) {
                throw new ServiceException(r.getMsg());
            }
            businessDetailMessage.setStepName(r.getData().getName());
        } catch (Exception e) {
            log.error("远程调用 -> [remoteGwjConfigService][getStepInfo]异常,异常信息: [{}]", e);
            return null;
        }
        List<GwjMaintenanceFundsBusinessBuild> gwjMaintenanceFundsBusinessBuilds = gwjMaintenanceFundsBusinessBuildService.selectGwjMaintenanceFundsBusinessBuildByBusinessId(bizId);
        businessDetailMessage.setBuilds(gwjMaintenanceFundsBusinessBuilds);
        return businessDetailMessage;
    }

    @Override
    public StepConfigInfoDTO getStepConfigInfo(GwjBusinessFlagType businessFlagType) {
        StepConfigInfoDTO stepConfigInfoDTO = new StepConfigInfoDTO();
        try {
            GwjConfBusinessFlag confBusinessFlag = remoteGwjConfigService.selectGwjConfBusinessFlagByBizFlagId(businessFlagType.getCode(), SecurityConstants.INNER).getData();
            if (ObjectUtil.isNull(confBusinessFlag)) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_BUSINESS_STEP_CONFIG_INFO) + "GwjConfBusinessFlag获取异常");
            }
            stepConfigInfoDTO.setConfBusinessFlag(confBusinessFlag);
            List<GwjConfStep> confStepList = remoteGwjConfigService.selectGwjConfStepListByFlagId(businessFlagType.getCode(), SecurityConstants.INNER).getData();
            if (CollectionUtil.isEmpty(confStepList)) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_BUSINESS_STEP_CONFIG_INFO) + "List<GwjConfStep>获取异常");
            }
            List<GwjConfStepDTO> confStepDTOList = BeanUtil.copyToList(confStepList, GwjConfStepDTO.class);
            stepConfigInfoDTO.setConfStepList(confStepDTOList);
            confStepDTOList.forEach(step -> {
                List<String> configs = remoteGwjConfigService.selectGwjConfStepConfigInfoCodeListByBizFlagId(step.getStepId(), SecurityConstants.INNER).getData();
                step.setConfigList(configs);
            });
        } catch (Exception e) {
            log.error("获取步骤配置信息失败 -> [{}]", e);
            return null;
        }
        return stepConfigInfoDTO;
    }

    /**
     * 获取已选中楼栋信息
     *
     * @param bizId 业务id
     * @return 获取已选中楼栋信息
     */
    @Override
    public List<GwjMaintenanceFundsBusinessBuild> getSelectBuilds(Long bizId) {
        return gwjMaintenanceFundsBusinessBuildService.selectGwjMaintenanceFundsBusinessBuildByBusinessId(bizId);
    }

    /**
     * 获取楼栋下房屋信息
     *
     * @param housesUnderBuildRequest 房子在构建请求
     * @return 楼栋下房屋信息
     */
    @Override
    public List<GwjMaintenanceFundsBusinessHouse> getHouseList(HousesUnderBuildRequest housesUnderBuildRequest) {
        return gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseList(new GwjMaintenanceFundsBusinessHouse() {
            {
                setBizId(housesUnderBuildRequest.getBizId());
                setBuildCode(housesUnderBuildRequest.getBuildCode());
                setAreaId(housesUnderBuildRequest.getAreaId());
            }
        });
    }

    @Override
    public List<AllocatedAmountListDTO> exportHouseList(AllocatedAmountRequest allocatedAmountRequest) {
        return gwjMaintenanceFundsBusinessHouseService.allocatedAmountList(allocatedAmountRequest);
    }

    /**
     * 获取业务详细信息 sql查询
     *
     * @param bizId 商业标识
     * @return {@link GetBusinessDetailDTO}
     */
    @Override
    public GetBusinessDetailDTO getBusinessDetailMessage(Long bizId) {
        return gwjMaintenanceFundsBusinessMapper.getBusinessDetailMessage(bizId);
    }

    /**
     * 获取分摊清册
     *
     * @param bizId 商业标识
     * @return {@link List}<{@link CostListDTO}>
     */
    @Override
    public List<CostListDTO> costList(Long bizId) {
        return gwjMaintenanceFundsBusinessMapper.costList(bizId);
    }

    // --------------------- 新增功能区 hmh start-------------------------------

    /**
     * 获取业主确认证明
     *
     * @param bizId 业务标识
     * @return {@link OwnerCheckProveDTO}
     */
    @Override
    public JSONObject getOwnerCheckProveIncludeVoteCount(Long bizId) {
        // GwjMaintenanceFundsBusiness gwjMaintenanceFundsBusiness =
        // gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        // if (ObjectUtil.isNull(gwjMaintenanceFundsBusiness)) {
        // throw new
        // ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) +
        // "GwjMaintenanceFundsBusiness为空");
        // }
        GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBizId(bizId);
        if (StringUtils.isNull(gwjMaintenanceFundsBusinessInfo)) {
            throw new ServiceException("未获取到对应的业务详情！");
        }
        GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity = gwjMaintenanceFundsBusinessCommunityService.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(bizId);
        GwjMaintenanceFundsBusinessAttachment maintenanceFundsBusinessAttachment = maintenanceFundsBusinessAttachmentService.getGwjMaintenanceFundsBusinessAttachment(new GwjMaintenanceFundsBusinessAttachment() {
            {
                setServerIdentification(gwjMaintenanceFundsBusinessInfo.getServerIdentification());
                setServerType(BusinessAttachmentServerTypeEnum.OWNER_CONFIRMATION_CERTIFICATE.getCode());
                setType(BusinessAttachmentTypeEnum.REPORT.getCode());
            }
        });
        Long attachmentId = StringUtils.isNull(maintenanceFundsBusinessAttachment) ? null : maintenanceFundsBusinessAttachment.getAttachmentId();
        String content = StringUtils.isNull(maintenanceFundsBusinessAttachment) ? "" : maintenanceFundsBusinessAttachment.getContent();
        String changeYear = null;
        String changeMonth = null;
        // 非空且为json
        if (StringUtils.isNotEmpty(content) && JSON.isValid(content)) {
            JSONObject json = JSON.parseObject(content);
            String jsonChangeYear = json.getString("changeYear");
            changeYear = StringUtils.isNotEmpty(jsonChangeYear) ? jsonChangeYear : changeYear;
            String jsonChangeMonth = json.getString("changeMonth");
            changeMonth = StringUtils.isNotEmpty(jsonChangeMonth) ? jsonChangeMonth : changeMonth;
        }
        // return new OwnerCheckProveDTO() {
        // {
        // // if (ObjectUtil.isNotEmpty(gwjMaintenanceFundsBusiness.getOwnerConfirmationCertificate())) {
        // // SaveOwnerCheckProveRequest saveOwnerCheckProveRequest =
        // // JSONUtil.toBean(gwjMaintenanceFundsBusiness.getOwnerConfirmationCertificate(),
        // // SaveOwnerCheckProveRequest.class);
        // // setChangeYear(saveOwnerCheckProveRequest.getChangeYear());
        // // setChangeMonth(saveOwnerCheckProveRequest.getChangeMonth());
        // // }
        // setCommunityName(gwjMaintenanceFundsBusinessCommunity.getCommunityName());
        // setMaintenanceItems(gwjMaintenanceFundsBusinessInfo.getMaintenanceItems());
        // setTotalHouseholds(gwjMaintenanceFundsBusinessInfo.getTotalHouseholds());
        // setTotalAreaInvolved(gwjMaintenanceFundsBusinessInfo.getTotalInvolvedArea());
        // setProjectBudgetAmount(gwjMaintenanceFundsBusinessInfo.getProjectBudgetAmount());
        // // 20230628 hmh 新增赋值字段 start
        // // setChangeYear(changeYear);
        // // setChangeMonth(changeMonth);
        // // end
        // }
        // };
        OwnerCheckProveDTO ocp = new OwnerCheckProveDTO();
        ocp.setCommunityName(gwjMaintenanceFundsBusinessCommunity.getCommunityName());
        ocp.setMaintenanceItems(gwjMaintenanceFundsBusinessInfo.getMaintenanceItems());
        ocp.setTotalHouseholds(gwjMaintenanceFundsBusinessInfo.getTotalHouseholds());
        ocp.setTotalAreaInvolved(gwjMaintenanceFundsBusinessInfo.getTotalInvolvedArea());
        ocp.setProjectBudgetAmount(gwjMaintenanceFundsBusinessInfo.getProjectBudgetAmount());
        // 20230628 hmh 新增赋值字段 start
        ocp.setChangeYear(changeYear);
        ocp.setChangeMonth(changeMonth);
        // end
        JSONObject rJson = JSONObject.from(ocp);
        // 添加附件ID
        rJson.put("attachmentId", attachmentId);
        // 获取投票统计结果
        GwjGVoteProjectStatisticsDataDTO ggvpsd = new GwjGVoteProjectStatisticsDataDTO();
        ggvpsd.setAgreeOwner(0);
        ggvpsd.setAgreeOwnerPercent(BigDecimal.ZERO);
        ggvpsd.setAgreeSizePercent(BigDecimal.ZERO);
        ggvpsd.setAgreeTotalSize(BigDecimal.ZERO);
        ggvpsd.setOwnerPercent(BigDecimal.ZERO);
        ggvpsd.setSizePercent(BigDecimal.ZERO);
        ggvpsd.setTotalOwner(0);
        ggvpsd.setTotalSize(BigDecimal.ZERO);
        ggvpsd.setTotalValidOwner(0);
        ggvpsd.setTotalValidSize(BigDecimal.ZERO);
        R<GwjGVoteProjectStatisticsDataDTO> voteStatisticsResult = remoteGwjVoteService.innerGVoteProjectStatistics(gwjMaintenanceFundsBusinessInfo.getBizNum(), SecurityConstants.INNER);
        if (R.isSuccess(voteStatisticsResult) && StringUtils.isNotNull(voteStatisticsResult.getData())) {
            GwjGVoteProjectStatisticsDataDTO rResult = voteStatisticsResult.getData();
            BeanUtils.copyBeanProp(ggvpsd, rResult);
        }
        // 这是临时测试用的 hmh start
        // GwjGVoteProjectStatisticsDataDTO gwjGVoteProjectStatisticsDataDTO = new GwjGVoteProjectStatisticsDataDTO();
        // gwjGVoteProjectStatisticsDataDTO.setTotalSize(new BigDecimal(1));
        // gwjGVoteProjectStatisticsDataDTO.setTotalOwner(1);
        // gwjGVoteProjectStatisticsDataDTO.setTotalValidOwner(1);
        // gwjGVoteProjectStatisticsDataDTO.setOwnerPercent(new BigDecimal(0.5));
        // gwjGVoteProjectStatisticsDataDTO.setTotalValidSize(new BigDecimal(1));
        // gwjGVoteProjectStatisticsDataDTO.setSizePercent(new BigDecimal(0.5));
        // gwjGVoteProjectStatisticsDataDTO.setAgreeOwner(1);
        // gwjGVoteProjectStatisticsDataDTO.setAgreeSizePercent(new BigDecimal(0.5));
        // gwjGVoteProjectStatisticsDataDTO.setAgreeOwnerPercent(new BigDecimal(0.5));
        // gwjGVoteProjectStatisticsDataDTO.setAgreeTotalSize(new BigDecimal(1));
        // rJson.putAll(JSONObject.from(gwjGVoteProjectStatisticsDataDTO));
        // end
        rJson.putAll(JSONObject.from(ggvpsd));
        return rJson;
    }

    /*
     * 20230629
     *
     * 获取过滤楼栋信息
     *
     * 后期看考虑是否去掉从库
     */
    @Override
    public List<GwjBaseBuild> getBuildsFilte(GwjBaseBuildRequest buildRequest) {
        return maintenanceFundsBusinessInnerService.getBuildsFilte(buildRequest);
    }

    /* 20230629
     *
     * 查询业务日志
     */
    @Override
    public List<GwjMaintenanceFundsBusinessLog> selectGwjMaintenanceFundsBusinessLogList(GwjMaintenanceFundsBusinessLog gwjMaintenanceFundsBusinessLog) {
        return gwjMaintenanceFundsBusinessLogService.selectGwjMaintenanceFundsBusinessLogList(gwjMaintenanceFundsBusinessLog);
    }

    /*
     * 20230705
     *
     * 导入房屋列表
     */
    @Override
    public String importHouseList(MultipartFile file, boolean updateSupport, Long bizId) throws Exception {
        ExcelUtil<GwjExpendOutsideBusinessHouseAndOwnerImp> util = new ExcelUtil<GwjExpendOutsideBusinessHouseAndOwnerImp>(GwjExpendOutsideBusinessHouseAndOwnerImp.class);
        // 外网支出导入
        InputStream is = file.getInputStream();
        List<GwjExpendOutsideBusinessHouseAndOwnerImp> gwjExpendOutsideBusinessHouseAndOwnerImpList = util.importExcel(is);
        int successNum = 0;
        int failureNum = 0;
        StringBuilder successMsg = new StringBuilder();
        StringBuilder failureMsg = new StringBuilder();
        // 缓存更新组
        List<GwjMaintenanceFundsBusinessHouse> upHouseData = new ArrayList<GwjMaintenanceFundsBusinessHouse>();
        List<GwjMaintenanceFundsBusinessOwner> upOwnerData = new ArrayList<GwjMaintenanceFundsBusinessOwner>();
        // 临时计算标准(注：暂时以首位计算标准为准，之前人员表格设计时候，计算标准未与房屋做匹配操作，仅存放于整体info信息中，这里只做临时处理)
        Integer calculationStandard = gwjExpendOutsideBusinessHouseAndOwnerImpList.get(0).getCalculationStandard();
        // 20240314 hmh 初始化累计数据 start
        // 总实际分摊金额
        BigDecimal totalActualAllocationAmount = BigDecimal.ZERO;
        // 总差额
        BigDecimal totalLackMoney = BigDecimal.ZERO;
        // 总自筹金额
        BigDecimal totaLselfRaiseMoney = BigDecimal.ZERO;
        // 总本次分摊总金额 = 决算拨出总金额
        BigDecimal allTotalAllocationMoney = BigDecimal.ZERO;
        // end
        for (GwjExpendOutsideBusinessHouseAndOwnerImp geobhao : gwjExpendOutsideBusinessHouseAndOwnerImpList) {
            // 校验导入参数
            BeanValidators.validateWithException(validator, geobhao);
            // 房屋标识码
            String houseCode = geobhao.getHouseCode();
            if (StringUtils.isNull(houseCode)) {

                failureMsg.append(geobhao.getHouseLocation() + "[" + geobhao.getHouseCode() + "]" + "导入失败！房屋编号不能为空！");
                throw new ServiceException(failureMsg.toString());
            }
            // 查询当前房屋是否存在
            GwjMaintenanceFundsBusinessHouse gmfbh = gwjMaintenanceFundsBusinessHouseService.selectGwjMaintenanceFundsBusinessHouseByBizIdAndHouseCode(bizId, houseCode);
            if (StringUtils.isNull(gmfbh)) {
                failureMsg.append(geobhao.getHouseLocation() + "[" + houseCode + "]" + "导入失败！未获取到当前房屋信息！");
                // throw new ServiceException(failureMsg.toString());
                continue;
            }
            try {
                // 更新房屋信息
                GwjMaintenanceFundsBusinessHouse upBusinessHouseInfo = new GwjMaintenanceFundsBusinessHouse();
                // 业务ID
                upBusinessHouseInfo.setBizId(bizId);
                // 房屋标识码
                upBusinessHouseInfo.setHouseCode(houseCode);
                // 坐落
                upBusinessHouseInfo.setHouseLocation(geobhao.getHouseLocation());
                // 房号
                upBusinessHouseInfo.setRoomNum(geobhao.getRoomNum());
                // 缴款面积
                upBusinessHouseInfo.setDepositSize(geobhao.getDepositSize());
                // 规划用途
                upBusinessHouseInfo.setUseType(geobhao.getUseType());
                // 计算标准
                // upBusinessHouseInfo.setca
                // 应分摊金额
                upBusinessHouseInfo.setAllocationMoney(geobhao.getAllocationMoney());
                // 差额
                BigDecimal lackMoney = geobhao.getLackMoney();
                upBusinessHouseInfo.setLackMoney(lackMoney);
                // 实际分摊金额
                BigDecimal actualAllocationMoney = geobhao.getActualAllocationMoney();
                upBusinessHouseInfo.setActualAllocationMoney(actualAllocationMoney);
                // 自筹金额
                BigDecimal selfRaiseMoney = geobhao.getSelfRaiseMoney();
                upBusinessHouseInfo.setSelfRaiseMoney(selfRaiseMoney);
                // 本次分摊总金额
                BigDecimal totalAllocationMoney = geobhao.getTotalAllocationMoney();
                upBusinessHouseInfo.setTotalAllocationMoney(totalAllocationMoney);
                // 存储房屋更新组
                upHouseData.add(upBusinessHouseInfo);
                // 更新业主信息
                GwjMaintenanceFundsBusinessOwner upBusinessOwnerInfo = new GwjMaintenanceFundsBusinessOwner();
                // 业务ID
                upBusinessOwnerInfo.setBizId(bizId);
                // 房屋标识码
                upBusinessOwnerInfo.setHouseCode(houseCode);
                // 业主姓名
                upBusinessOwnerInfo.setOwnerName(geobhao.getOwnerName());
                // 业主身份证号
                upBusinessOwnerInfo.setCardNum(geobhao.getCardNum());
                // 业主手机后
                upBusinessOwnerInfo.setPhone(geobhao.getPhone());
                // 存储业主更新组
                upOwnerData.add(upBusinessOwnerInfo);
                // 20240314 金额累加计算 s
                // 累加导入总实际分摊金额
                totalActualAllocationAmount = totalActualAllocationAmount.add(actualAllocationMoney).setScale(2, RoundingMode.HALF_UP);
                // 累加导入总差额
                totalLackMoney = totalLackMoney.add(lackMoney).setScale(2, RoundingMode.HALF_UP);
                // 累加导入总自筹金额
                totaLselfRaiseMoney = totaLselfRaiseMoney.add(selfRaiseMoney).setScale(2, RoundingMode.HALF_UP);
                // 累加导入总本次分摊总金额
                allTotalAllocationMoney = allTotalAllocationMoney.add(totalAllocationMoney).setScale(2, RoundingMode.HALF_UP);
                // e
                // 修改操作
                if (upHouseData.size() == 100 && upOwnerData.size() == 100) {
                    // 调用更新组
                    upImportHouseAndOwner(upHouseData, upOwnerData);
                }
            } catch (Exception e) {
                failureNum++;
                String msg = "<br/>" + failureNum + "、房屋编号： " + houseCode + ",房屋和业主数据导入失败：";
                log.error(msg, e);
            }
        }
        // 对余留数据进行修改
        if (upHouseData.size() > 0 && upOwnerData.size() > 0) {
            // 调用更新组
            upImportHouseAndOwner(upHouseData, upOwnerData);
        }
        // 不为空则重新赋值计算标准
        if (StringUtils.isNotNull(calculationStandard)) {
            // 20230724进行业务信息更新
            // 注：后期需要进行修改，取消该方法，将计算标准值指向房屋
            gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfoByBizId(new GwjMaintenanceFundsBusinessInfo() {
                /**
                *
                */
                // private static final long serialVersionUID = 5961198304185333027L;

                {
                    setBizId(bizId);
                    setCalculationStandard(calculationStandard);
                }
            });
            GwjMaintenanceFundsBusinessInfo upGwjMaintenanceFundsBusinessInfo = new GwjMaintenanceFundsBusinessInfo();
            upGwjMaintenanceFundsBusinessInfo.setBizId(bizId);
            upGwjMaintenanceFundsBusinessInfo.setCalculationStandard(calculationStandard);
            // 修改总实际分摊金额 导入时候不另外计算。就为当前导入数据的累加和
            upGwjMaintenanceFundsBusinessInfo.setActualAllocationAmount(totalActualAllocationAmount);
            // 决算拨出总金额 = 差额+实际分摊金额+自筹金额 导入时候不另外计算。就为当前导入数据的累加和
            upGwjMaintenanceFundsBusinessInfo.setTotalAllocatedSettlementAmount(allTotalAllocationMoney);
            gwjMaintenanceFundsBusinessInfoService.updateGwjMaintenanceFundsBusinessInfoByBizId(upGwjMaintenanceFundsBusinessInfo);
        }

        if (failureNum > 0) {
            throw new ServiceException("很抱歉，导入失败！共 " + failureNum + " 条数据格式不正确");
        } else {
            // successMsg.insert(0, "恭喜您，数据已全部导入成功！共 " + successNum + " 条，数据如下：");
            successMsg.insert(0, "恭喜您，数据已全部导入成功！");
        }
        if (is != null) {
            is.close();
        }
        return successMsg.toString();
    }

    /**
     * 修改导入的房屋和业主
     *
     * @param inHouseData
     * @param inOwnerData
     */
    private void upImportHouseAndOwner(List<GwjMaintenanceFundsBusinessHouse> inHouseData, List<GwjMaintenanceFundsBusinessOwner> inOwnerData) {
        if ((StringUtils.isNull(inHouseData) && inHouseData.size() == 0) || (StringUtils.isNull(inOwnerData) && inOwnerData.size() == 0)) {
            return;
        }
        // 设置ExecutorType.BATCH原理：把SQL语句发个数据库，数据库预编译好，数据库等待需要运行的参数，接收到参数后一次运行，ExecutorType.BATCH只打印一次SQL语句，多次设置参数步骤
        SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH);
        try {
            gwjMaintenanceFundsBusinessHouseService.updateBatchMaintenanceFundsBusinessHouseByBizIdAndHouseCode(inHouseData);
            // for(int i=0;i<inHouseData.size();i++) {
            // inOwnerData.get(i).setHouseCode(inHouseData.get(i).getHouseCode());
            // }
            gwjMaintenanceFundsBusinessOwnerService.updateBatchGwjMaintenanceFundsBusinessOwnerByBizIdAndHouseCode(inOwnerData);
            session.commit();
        } catch (Exception e) {
            // throw new ServiceException("未获取到对于项目下的楼栋数据，请核对后再导入");
            e.printStackTrace();
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

    /**
     * 步骤回调
     *
     * @param jsonMsg 回调信息
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R<Boolean> resultNotify(String jsonMsg) {
        ResultNotifyMessage resultNotifyMessage = JSONUtil.toBean(jsonMsg, ResultNotifyMessage.class);
        // 查询外网业务信息
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = this.getGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusinessRequest() {
            {
                // 设置外网业务标志
                setOutServerIdentification(resultNotifyMessage.getOutServerIdentification());
            }
        });
        // 判断业务信息是否为空
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            maintenanceFundsBusiness = this.getGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusinessRequest() {
                {
                    // 设置外网业务标志
                    setServerIdentification(resultNotifyMessage.getOutServerIdentification());
                }
            });
            if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_RETREAT) + "GwjMaintenanceFundsBusiness为空");

            }
        }
        // 判断是否为维修资金申请一次拨付或应急维修资金申请一次拨付
        if (GwjBusinessFlagType.EXPEND_OUTSIDE_URGENT.getCode().equals(maintenanceFundsBusiness.getBizFlagId()) || GwjBusinessFlagType.EXPEND_OUTSIDE.getCode().equals(maintenanceFundsBusiness.getBizFlagId())) {
            GwjMaintenanceFundsBusinessInfo gwjMaintenanceFundsBusinessInfo = gwjMaintenanceFundsBusinessInfoService.selectGwjMaintenanceFundsBusinessInfoByBusinessId(maintenanceFundsBusiness.getBizId());
            if (ObjectUtil.isEmpty(gwjMaintenanceFundsBusinessInfo)) {
                throw new ServiceException("未查询到对应业务信息详情");
            } else {
                if (AppropriationWayEnum.ONE.getCode().equals(gwjMaintenanceFundsBusinessInfo.getAppropriationWay())) {
                    GwjConfStep confStep = remoteGwjConfigService.selectNextGwjConfStepByFlagId(maintenanceFundsBusiness.getBizFlagId(), maintenanceFundsBusiness.getStepId(), SecurityConstants.INNER).getData();
                    if (ObjectUtil.isEmpty(confStep)) {
                        throw new ServiceException("未查询到对应步骤信息");
                    }
                    // 判断下一步是否为财务对账
                    if (confStep.getName().equals(BusinessStatusEnum.FINANCE_CHECK.getInfo())) {
                        // 一次拨付跳过财务对账步骤
                        maintenanceFundsBusiness.setStepId(confStep.getStepId());
                    }

                }
            }
        }
        GwjMaintenanceFundsBusiness oldBusiness = maintenanceFundsBusiness;

        // 更新外网业务信息
        GwjMaintenanceFundsBusiness business = this.updateGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusiness() {
            {
                // 设置业务主键
                setBizId(oldBusiness.getBizId());
                // 查询下一个步骤
                try {
                    GwjConfStep confStep = remoteGwjConfigService.selectNextGwjConfStepByFlagId(oldBusiness.getBizFlagId(), oldBusiness.getStepId(), SecurityConstants.INNER).getData();
                    setStepId(confStep.getStepId());
                    // 1 判断是否案例回顾/办结
                    if (StringUtils.inStringIgnoreCase(confStep.getName(), "办结", "完结", "案例回顾")) {
                        // 设置为办结
                        setServerStatus(BusinessServerStatusEnum.FINISH.getCode());
                    }
                } catch (Exception e) {
                    log.error("GwjConfStep获取异常 -> [{}]", e);
                    throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.CONF_STEP_CONFIG_CHECK) + "获取GwjConfStep异常");
                }

            }

        });
        // 判断业务是否更新成功
        if (ObjectUtil.isNull(business)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_RETREAT) + "GwjMaintenanceFundsBusiness更新失败");
        }
        // 插入日志
        int insertFlag = gwjMaintenanceFundsBusinessLogService.insertGwjMaintenanceFundsBusinessLog(new GwjMaintenanceFundsBusinessLog() {
            {
                setAcceptTime(LocalDateTime.now());
                setStepId(business.getStepId());
                setBizId(business.getBizId());
                setOperId(resultNotifyMessage.getOperId());
                setOperName(resultNotifyMessage.getOperName());
                setContent(resultNotifyMessage.getContent());
                setResult(GwjBusinessLogResult.SUBMIT.getCode());
            }
        });
        if (ObjectUtil.equal(insertFlag, FlagStatusEnum.FAL.getCode())) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.CONF_STEP_CONFIG_CHECK) + "GwjMaintenanceFundsBusinessLog新增失败");
        }
        return R.ok(Boolean.TRUE);
    }

    /**
     * 回退步骤回调
     *
     * @param jsonMsg 回调信息
     * @return
     */
    @Override
    public R<Boolean> rollbackResultNotify(String jsonMsg) {
        ResultNotifyMessage resultNotifyMessage = JSONUtil.toBean(jsonMsg, ResultNotifyMessage.class);
        // 查询外网业务信息
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = this.getGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusinessRequest() {
            {
                // 设置外网业务标志
                setOutServerIdentification(resultNotifyMessage.getOutServerIdentification());
            }
        });
        // 判断业务信息是否为空
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            maintenanceFundsBusiness = this.getGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusinessRequest() {
                {
                    // 设置外网业务标志
                    setServerIdentification(resultNotifyMessage.getOutServerIdentification());
                }
            });
            if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_RETREAT) + "GwjMaintenanceFundsBusiness为空");
            }
        }
        GwjMaintenanceFundsBusiness oldBusiness = maintenanceFundsBusiness;
        // 更新外网业务信息
        GwjMaintenanceFundsBusiness business = this.updateGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusiness() {
            {
                // 设置业务主键
                setBizId(oldBusiness.getBizId());
                // setStatus(BusinessStatusEnum.FALLBACK.getCode());
                // setServerStatus(BusinessServerStatusEnum.FALLBACK.getCode());
                // 查询下一个步骤
                try {
                    GwjConfStep confStep = remoteGwjConfigService.selectPreviousGwjConfStepByFlagId(oldBusiness.getBizFlagId(), oldBusiness.getStepId(), SecurityConstants.INNER).getData();
                    setStepId(confStep.getStepId());
                } catch (Exception e) {
                    log.error("GwjConfStep获取异常 -> [{}]", e);
                    throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.CONF_STEP_CONFIG_CHECK) + "获取GwjConfStep异常");
                }
            }

        });
        // 判断业务是否更新成功
        if (ObjectUtil.isNull(business)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_RETREAT) + "GwjMaintenanceFundsBusiness更新失败");
        }
        // 插入日志
        int insertFlag = gwjMaintenanceFundsBusinessLogService.insertGwjMaintenanceFundsBusinessLog(new GwjMaintenanceFundsBusinessLog() {
            {
                setAcceptTime(LocalDateTime.now());
                setStepId(business.getStepId());
                setBizId(business.getBizId());
                setOperId(resultNotifyMessage.getOperId());
                setOperName(resultNotifyMessage.getOperName());
                setContent(resultNotifyMessage.getContent());
                setResult("8");
            }
        });
        if (ObjectUtil.equal(insertFlag, FlagStatusEnum.FAL.getCode())) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.CONF_STEP_CONFIG_CHECK) + "GwjMaintenanceFundsBusinessLog新增失败");
        }
        return R.ok(Boolean.TRUE);
    }

    /**
     * 预受理审核
     *
     * @param jsonMsg 预受理审核参数
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R<Boolean> preAcceptExamine(String jsonMsg) {
        PreAcceptExamineMessage preAcceptExamineMessage = JSONUtil.toBean(jsonMsg, PreAcceptExamineMessage.class);
        if (ObjectUtil.isNull(preAcceptExamineMessage)) {
            log.error("预受理审核JSON数据转换失败");
            throw new ServiceException("预受理审核JSON数据转换失败");
        }
        try {
            preAcceptExamineMessage.checkNull();
        } catch (Exception e) {
            log.error("参数校验异常 --> [{}]", e);
            throw new ServiceException("参数校验异常 --> [{" + e + "}]");

        }
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = this.getGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusinessRequest() {
            {
                setServerIdentification(preAcceptExamineMessage.getOutServerIdentification());
            }
        });
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            maintenanceFundsBusiness = this.getGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusinessRequest() {
                {
                    setOutServerIdentification(preAcceptExamineMessage.getOutServerIdentification());
                }
            });
            if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
                throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_EXAMINE) + "GwjMaintenanceFundsBusiness为空");

            }
        }
        GwjMaintenanceFundsBusiness oldBusiness = maintenanceFundsBusiness;
        GwjMaintenanceFundsBusiness business = this.updateGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusiness() {
            {
                // 20230629 hmh 取消内网推送二次补件状态情况下修改了外网申请人信息 start
                // setCurrentOperId(preAcceptExamineMessage.getOperId());
                // setCurrentOperName(preAcceptExamineMessage.getOperName());
                // end
                setStatus(BusinessStatusEnum.SAVE.getCode());
                setBizId(oldBusiness.getBizId());
                setVoteFlag(FlagStatusEnum.SUC.getCode());
                setSupplementFlag(FlagStatusEnum.SUC.getCode());
                setOutServerIdentification(preAcceptExamineMessage.getServerIdentification());
                if (ObjectUtil.notEqual(BusinessServerStatusEnum.RETREAT_PARTS, oldBusiness.getStatus())) {
                    try {
                        // 20230905 临时增加判断，应急预受理没有二次补件，这里用于进行特别区分
                        if (GwjBusinessFlagType.EXPEND_OUTSIDE_URGENT.getCode() != oldBusiness.getBizFlagId()) {
                            GwjConfStep confStep = remoteGwjConfigService.selectNextGwjConfStepByFlagId(oldBusiness.getBizFlagId(), oldBusiness.getStepId(), SecurityConstants.INNER).getData();
                            setStepId(confStep.getStepId());
                        }
                    } catch (Exception e) {
                        log.error("GwjConfStep获取异常 -> [{}]", e);
                        throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_EXAMINE) + "获取GwjConfStep异常");
                    }
                }
            }
        });
        if (ObjectUtil.isNull(business)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_EXAMINE) + "GwjMaintenanceFundsBusiness更新失败");
        }
        int insertFlag = gwjMaintenanceFundsBusinessLogService.insertGwjMaintenanceFundsBusinessLog(new GwjMaintenanceFundsBusinessLog() {
            {
                setAcceptTime(LocalDateTime.now());
                setStepId(oldBusiness.getStepId());
                setBizId(oldBusiness.getBizId());
                setOperId(preAcceptExamineMessage.getOperId());
                setOperName(preAcceptExamineMessage.getOperName());
                setContent(preAcceptExamineMessage.getContent());
                setResult(GwjBusinessLogResult.PASS.getCode());
            }
        });
        if (ObjectUtil.equal(insertFlag, FlagStatusEnum.FAL.getCode())) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_RETREAT) + "GwjMaintenanceFundsBusinessLog新增失败");
        }
        return R.ok(Boolean.TRUE);
    }

    @Override
    public JSONObject getOwnerCommentsJSON(Long bizId) {
        JSONObject result = new JSONObject();
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = gwjMaintenanceFundsBusinessMapper.selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            // throw new
            // ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.GET_APPLICATION_REPORT) +
            // "GwjMaintenanceFundsBusiness为空");
            throw new ServiceException("未获取到对应业务信息！");
        }
        // 查询附件内容，存在调用附件内容，不存在则改调查询业务信息

        GwjMaintenanceFundsBusinessAttachment gmfba = maintenanceFundsBusinessAttachmentService.getGwjMaintenanceFundsBusinessAttachment(new GwjMaintenanceFundsBusinessAttachment() {

            /**
             *
             */
            private static final long serialVersionUID = 3529262648180342793L;

            {
                setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
                setType(2);
                setServerType(3);
            }

        });
        // 不为空，从content内转换
        // 是否需要查询
        boolean isSelect = false;
        if (StringUtils.isNotNull(gmfba)) {
            String content = gmfba.getContent();
            if (StringUtil.isEmpty(content)) {
                log.error("查看业主征求意见 内容为空！" + content);
                isSelect = true;
            }
            result = JSONObject.parseObject(content);
        }

        // 开启分页
        PageUtils.startPage();
        // 获取投票结果
        List<GwjExpendHouseAndOwnerDTO> voteList = gwjExpendOutsideBaseHouseService.selectHouseAndOwnerVoteInfosByBizIdAndBizNum(bizId, maintenanceFundsBusiness.getBizNum());
        // 需要查询
        if (!isSelect) {
            Map<String, String> selectMap = gwjMaintenanceFundsBusinessInfoService.getOwnerComments(bizId);
            if (selectMap.size() > 0) {
                result.putAll(selectMap);
            }
        }
        result.put("tableDataInfo", PageUtils.getDataTable(voteList));
        return result;
    }

    /**
     * 业主证明内部调用
     *
     * @param outServerIdentification 外网业务标识
     * @return
     */
    @Override
    public R<JSONObject> ownerCheckInner(String outServerIdentification, Integer bizFlagId) {
        // 查询业务信息
        GwjMaintenanceFundsBusiness business = gwjMaintenanceFundsBusinessMapper.getGwjMaintenanceFundsBusinessOne(new GwjMaintenanceFundsBusinessRequest() {
            {
                setOutServerIdentification(outServerIdentification);
                setBizFlagId(bizFlagId);
            }
        });
        if (ObjectUtil.isEmpty(business)) {
            throw new ServiceException("未查询到对应业务信息");
        }
        return R.ok(this.getOwnerCheckProveIncludeVoteCount(business.getBizId()));
    }

    /**
     * 二次补件
     * <p>
     * 20230721
     */
    @ConfStepConfigCheck(bizId = "#bizId", stepConfigInfo = {StepConfigInfoEnum.SUBMIT}, businessStatus = {BusinessStatusEnum.SAVE, BusinessStatusEnum.RETREAT_PARTS})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int preAcceptSecondSubmitByBizId(Long bizId) {
        GwjMaintenanceFundsBusiness maintenanceFundsBusiness = selectGwjMaintenanceFundsBusinessByBusinessId(bizId);
        if (ObjectUtil.isNull(maintenanceFundsBusiness)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "GwjMaintenanceFundsBusiness为空");
        }
        List<GwjMaintenanceFundsBusinessAttachment> maintenanceFundsBusinessAttachmentList = maintenanceFundsBusinessAttachmentService.getGwjMaintenanceFundsBusinessAttachmentList(new GetAttachmentInfoRequest() {
            {
                setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
                setServerTypeList(
                    ListUtil.toList(BusinessAttachmentServerTypeEnum.PUBLICITY_PHOTOS.getCode(), BusinessAttachmentServerTypeEnum.APPLICANT_MATERIALS.getCode(), BusinessAttachmentServerTypeEnum.MAINTENANCE_CONTRACT.getCode(), BusinessAttachmentServerTypeEnum.ADVANCE_PAYMENT_RECEIPT.getCode(), BusinessAttachmentServerTypeEnum.APPLICATION_REPORT.getCode(), BusinessAttachmentServerTypeEnum.OWNER_CONFIRMATION_CERTIFICATE.getCode(), BusinessAttachmentServerTypeEnum.OWNER_COMMENTS.getCode()));
            }
        });

        // 要提示的内容
        // 10、维修资金预付款收款收据和100、其他可以非必传。剩下都是必传
        // 临时校验必传文件组
        Integer[] checkAttachment = new Integer[] {1, 3, 5, 6, 8, 9};
        List<Integer> checkAttachmentList = Arrays.asList(checkAttachment);
        // checkAttachmentList.stream().collect(Collectors.toMap(, null));
        // 如果空全提示
        // if (StringUtils.isEmpty(maintenanceFundsBusinessAttachmentList)) {
        //
        // }
        // 对类型进行过滤
        if (StringUtils.isNotEmpty(maintenanceFundsBusinessAttachmentList) && maintenanceFundsBusinessAttachmentList.size() > 0) {

            // maintenanceFundsBusinessAttachmentList.stream().filter(e ->
            // checkAttachmentList.contains(e.getServerType()));
            List<Integer> serverTypeList = maintenanceFundsBusinessAttachmentList.stream().map(item -> item.getServerType()).collect(Collectors.toList());
            // filter(item ->
            // serverTypeList.contains(item))这种情况下只会将符合条件的筛选出来，!serverTypeList.contains(item)将不是checkAttachment内的取出来
            checkAttachmentList = checkAttachmentList.stream().filter(item -> !serverTypeList.contains(item)).collect(Collectors.toList());

        }
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < checkAttachmentList.size(); i++) {
            String value = BusinessAttachmentServerTypeEnum.getEnumVuale(checkAttachmentList.get(i), 0);
            sb.append(i + 1).append(":").append(value).append(";");
        }
        if (sb.length() > 0) {
            sb.insert(0, "您缺少材料如下:");
            sb.append("请提交后再操作！");
            throw new ServiceException(sb.toString());
        }
        // List<BusinessAttachmentServerTypeEnum> serverTypeEnumList =
        // maintenanceFundsBusinessAttachmentService.checkNull(() -> {
        // return Optional.of(maintenanceFundsBusinessAttachmentList);
        // }, false, ListUtil.toList(BusinessAttachmentServerTypeEnum.APPLICATION_REPORT,
        // BusinessAttachmentServerTypeEnum.PUBLICITY_PHOTOS, BusinessAttachmentServerTypeEnum.APPLICANT_MATERIALS,
        // BusinessAttachmentServerTypeEnum.MAINTENANCE_CONTRACT,
        // BusinessAttachmentServerTypeEnum.ADVANCE_PAYMENT_RECEIPT));
        // if (CollectionUtil.isNotEmpty(serverTypeEnumList)) {
        // throw new ServiceException("附件" + serverTypeEnumList.get(0).getInfo() + "未提交,请先上传");
        // }
        // 取消文件校验
        Optional.ofNullable(((IGwjMaintenanceFundsBusinessService)AopContext.currentProxy()).updateGwjMaintenanceFundsBusiness(new GwjMaintenanceFundsBusiness() {
            {
                setBizId(bizId);
                setStatus(BusinessStatusEnum.SUBMIT.getCode());
                setServerStatus(BusinessServerStatusEnum.NORMAL.getCode());
            }
        })).<ServiceException>orElseThrow(() -> {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "GwjMaintenanceFundsBusiness更新失败");
        });
        int insertFlag = gwjMaintenanceFundsBusinessLogService.insertGwjMaintenanceFundsBusinessLog(new GwjMaintenanceFundsBusinessLog() {
            {
                setResult(GwjBusinessLogResult.SUBMIT.getCode());
                setBizId(maintenanceFundsBusiness.getBizId());
                setStepId(maintenanceFundsBusiness.getStepId());
            }
        });
        if (ObjectUtil.equal(FlagStatusEnum.FAL.getCode(), insertFlag)) {
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "GwjMaintenanceFundsBusinessLog新增失败");
        }

        PreAcceptSecondSubmitMessage preAcceptSecondSubmitMessage = new PreAcceptSecondSubmitMessage();
        preAcceptSecondSubmitMessage.setBizId(maintenanceFundsBusiness.getBizId());
        preAcceptSecondSubmitMessage.setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
        preAcceptSecondSubmitMessage.setOutServerIdentification(maintenanceFundsBusiness.getOutServerIdentification());
        preAcceptSecondSubmitMessage.setMaintenanceFundsBusinessAttachmentList(maintenanceFundsBusinessAttachmentList);

        // 提交到内网审核
        String tag = maintenanceFundsBusinessConfiguration.tagProperties().getPreAcceptSecondSubmit();
        MqSendResult mqSendResult = mqSendMessageHandler.syncSend(new MaintenanceFundsMqMessageBody() {
            {
                setJsonMsg(JSONUtil.toJsonStr(preAcceptSecondSubmitMessage));
                setServerIdentification(maintenanceFundsBusiness.getServerIdentification());
            }
        }, new MaintenanceFundsBusinessConfiguration.MaintenanceFundsBusinessSendRequest(tag, null));
        if (mqSendResult.isSuccess()) {
            return FlagStatusEnum.SUC.getCode();
        } else {
            log.error("公维金资金申请提交数据到内网MQ异常 -> [{}]", mqSendResult.getMessage());
            throw new ServiceException(GwjEnumUtils.getEnumConstantMsg(MaintenanceFundsErrorEnum.PRE_ACCEPT_SECOND_SUBMIT) + "公维金资金申请提交数据到内网MQ异常");
        }
    }

    /* 
     * 得到一步配置信息 获取步骤按钮权限信息
     */
    @Override
    public JSONObject getStepConfigInfoToJson(GwjBusinessFlagType businessFlagType) {
        R<JSONObject> result = remoteGwjConfigService.selectGwjConfBusinessFlagInfoByBizFlagId(businessFlagType.getCode(), SecurityConstants.INNER);
        if (R.isError(result) || StringUtils.isNull(result.getData())) {
            throw new ServiceException("未获取到对应配置步骤列表");
        }
        return result.getData();
    }
    // ---------------------新增功能区 end-------------------------------

}
